client

package
v0.0.0-...-1ecef25 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: MPL-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var OrganizationID = schema.Column{
	Name:       "organization_id",
	Type:       arrow.BinaryTypes.String,
	PrimaryKey: true,
	NotNull:    true,
	Resolver:   ResolveOrganizationID,
}

Functions

func ByOrganization

func ByOrganization(meta schema.ClientMeta) []schema.ClientMeta

func MockTestHelper

func MockTestHelper(t *testing.T, table *schema.Table, createService func(*httprouter.Router) error)

func New

func New(ctx context.Context, logger zerolog.Logger, spec Spec) (schema.ClientMeta, error)

func ResolveOrganizationID

func ResolveOrganizationID(_ context.Context, meta schema.ClientMeta, r *schema.Resource, c schema.Column) error

func SingleOrganization

func SingleOrganization(meta schema.ClientMeta) []schema.ClientMeta

func Transform

func Transform(tables schema.Tables) schema.Tables

Types

type Client

type Client struct {
	*snyk.Client

	Spec           Spec
	OrganizationID string
	Organizations  []snyk.Organization
	// contains filtered or unexported fields
}

func (*Client) ID

func (c *Client) ID() string

func (*Client) Logger

func (c *Client) Logger() *zerolog.Logger

func (*Client) RetryOnError

func (c *Client) RetryOnError(ctx context.Context, tableName string, f func() error) error

RetryOnError will run the given resolver function and retry on rate limit exceeded errors or other retryable errors (like internal server errors) after waiting some amount of time.

func (*Client) WantOrganization

func (c *Client) WantOrganization(organizationID string) bool

func (*Client) WithOrganization

func (c *Client) WithOrganization(organizationID string) schema.ClientMeta

type SnykLogger

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

func (*SnykLogger) Log

func (l *SnykLogger) Log(args ...any)

type SnykReportingIssuesOptions

type SnykReportingIssuesOptions struct {
	From   string `json:"from"`   // e.g. 2020-01-01
	To     string `json:"to"`     // e.g. 2020-01-01
	Period string `json:"period"` // e.g. 1d, 365d
}

SnykReportingIssuesOptions accepts these combinations: - `from` + `to` - `from` (default `to` is now) - `period` (relative to now) Other combinations should fail validation.

func (SnykReportingIssuesOptions) FromTime

func (s SnykReportingIssuesOptions) FromTime() time.Time

func (SnykReportingIssuesOptions) ToTime

type Spec

type Spec struct {
	// APIKey required to access Snyk API
	APIKey string `json:"api_key,omitempty"`

	// Organizations is a list of organizations to fetch information from.
	// By default, will fetch from all organizations available for user.
	Organizations []string `json:"organizations,omitempty"`

	// EndpointURL is an optional parameter to override the API URL for snyk.Client.
	// It defaults to https://api.snyk.io/api/
	EndpointURL string `json:"endpoint_url,omitempty"`

	// Retries is an optional parameter to override the default number of retries for retryable requests.
	Retries int `json:"retries,omitempty"`

	// RetryDelaySeconds is an optional parameter to override the default backoff time for retryable requests.
	RetryDelaySeconds int `json:"retry_delay_seconds,omitempty"`

	TableOptions TableOptions `json:"table_options,omitempty"`

	Concurrency int `json:"concurrency,omitempty"`
}

func (*Spec) SetDefaults

func (s *Spec) SetDefaults()

func (*Spec) Validate

func (s *Spec) Validate() error

type TableOptions

type TableOptions struct {
	SnykReportingIssues SnykReportingIssuesOptions `json:"snyk_reporting_issues"`
}

func (TableOptions) Validate

func (t TableOptions) Validate() error

Jump to

Keyboard shortcuts

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