rest_api

package
v2.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScopeAllRead = "vanta-api.all:read"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BearerTokenStore

type BearerTokenStore struct {
	*StaticTokenStore
}

BearerTokenStore is a convenience wrapper for Bearer token authentication

func NewBearerTokenStore

func NewBearerTokenStore(token string) *BearerTokenStore

NewBearerTokenStore creates a new Bearer token store

func (*BearerTokenStore) SetBearerToken

func (b *BearerTokenStore) SetBearerToken(token string)

SetBearerToken updates the Bearer token

type GetOauthTokenInput

type GetOauthTokenInput struct {
	ClientID     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
	Scope        string `json:"scope"`
	GrantType    string `json:"grant_type"`
}

GetOauthTokenInput represents the OAuth token request

type GetOauthTokenOutput

type GetOauthTokenOutput struct {
	AccessToken string `json:"access_token"`
	TokenType   string `json:"token_type"`
	ExpiresIn   int    `json:"expires_in"`
	Scope       string `json:"scope"`
}

GetOauthTokenOutput represents the OAuth token response

type Option

type Option func(*vanta)

Option represents a functional option for configuring the client

func WithBaseURL

func WithBaseURL(url string) Option

WithBaseURL sets the base URL for the Vanta API

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) Option

WithHTTPClient sets a custom HTTP client

func WithOAuthCredentials

func WithOAuthCredentials(clientID, clientSecret string) Option

WithOAuthCredentials sets OAuth client credentials for automatic token refresh

func WithScopes

func WithScopes(scopes ...string) Option

WithScopes sets the OAuth scopes for the client

func WithToken

func WithToken(token string) Option

WithToken sets a static Bearer token (bypasses OAuth)

type RestClient

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

RestClient wraps the Vanta API client with additional functionality

func NewRestClient

func NewRestClient(baseURL string, tokenStore TokenStore) *RestClient

NewRestClient creates a new REST client instance

func (*RestClient) GetComputerByID

func (c *RestClient) GetComputerByID(ctx context.Context, id string) (*model.Computer, error)

GetComputerByID retrieves a specific computer by its ID

func (*RestClient) GetGroupByID

func (c *RestClient) GetGroupByID(ctx context.Context, id string) (*model.GroupItem, error)

GetGroupByID retrieves a specific group by its ID

func (*RestClient) GetIntegrationByID

func (c *RestClient) GetIntegrationByID(ctx context.Context, id string) (*model.Integration, error)

GetIntegrationByID retrieves a specific integration by its ID

func (*RestClient) GetMonitorByID

func (c *RestClient) GetMonitorByID(ctx context.Context, id string) (*model.Monitor, error)

GetMonitorByID retrieves a specific monitor/test by its ID

func (*RestClient) GetPersonByID

func (c *RestClient) GetPersonByID(ctx context.Context, id string) (*model.Person, error)

GetPersonByID retrieves a specific person by their ID

func (*RestClient) GetPolicyByID

func (c *RestClient) GetPolicyByID(ctx context.Context, id string) (*model.PolicyItem, error)

GetPolicyByID retrieves a specific policy by its ID

func (*RestClient) GetTestByID

func (c *RestClient) GetTestByID(ctx context.Context, id string) (*model.Test, error)

GetTestByID retrieves a specific comprehensive test by its ID

func (*RestClient) GetVendorByID

func (c *RestClient) GetVendorByID(ctx context.Context, id string) (*model.Vendor, error)

GetVendorByID retrieves a specific vendor by its ID

func (*RestClient) GetVulnerabilityByID added in v2.2.0

func (c *RestClient) GetVulnerabilityByID(ctx context.Context, id string) (*model.Vulnerability, error)

GetVulnerabilityByID retrieves a specific vulnerability by its ID

func (*RestClient) ListComputers

func (c *RestClient) ListComputers(ctx context.Context, options *model.ListComputersOptions) (*model.ListComputersOutput, error)

ListComputers retrieves a paginated list of computers from Vanta

func (*RestClient) ListConnectedIntegrations

func (c *RestClient) ListConnectedIntegrations(ctx context.Context, options *model.ListIntegrationsOptions) (*model.ListIntegrationsOutput, error)

ListConnectedIntegrations retrieves a paginated list of integrations from Vanta

func (*RestClient) ListEvidence

func (c *RestClient) ListEvidence(ctx context.Context, auditID string, options *model.ListEvidenceOptions) (*model.ListEvidenceOutput, error)

ListEvidence retrieves a list of evidence for a specific audit

func (*RestClient) ListGroups

func (c *RestClient) ListGroups(ctx context.Context, options *model.ListGroupsOptions) (*model.ListGroupsOutput, error)

ListGroups retrieves a paginated list of groups from Vanta

func (*RestClient) ListMonitors

func (c *RestClient) ListMonitors(ctx context.Context, options *model.ListMonitorsOptions) (*model.MonitorResults, error)

ListMonitors retrieves a paginated list of monitors/tests from Vanta

func (*RestClient) ListPeople

func (c *RestClient) ListPeople(ctx context.Context, options *model.ListPeopleOptions) (*model.ListPeopleOutput, error)

ListPeople retrieves a paginated list of people from Vanta

func (*RestClient) ListPolicies

func (c *RestClient) ListPolicies(ctx context.Context, options *model.ListPoliciesOptions) (*model.ListPoliciesOutput, error)

ListPolicies retrieves a paginated list of policies from Vanta

func (*RestClient) ListTestEntities

func (c *RestClient) ListTestEntities(ctx context.Context, testID string, options *model.ListTestEntitiesOptions) (*model.TestEntitiesResults, error)

ListTestEntities retrieves a paginated list of entities for a specific test

func (*RestClient) ListTests

func (c *RestClient) ListTests(ctx context.Context, options *model.ListTestsOptions) (*model.TestResults, error)

ListTests retrieves a paginated list of comprehensive tests from Vanta

func (*RestClient) ListVendors

func (c *RestClient) ListVendors(ctx context.Context, options *model.ListVendorsOptions) (*model.ListVendorsOutput, error)

ListVendors retrieves a paginated list of vendors from Vanta

func (*RestClient) ListVulnerabilities added in v2.2.0

ListVulnerabilities retrieves a paginated list of vulnerabilities from Vanta

func (*RestClient) SetHTTPClient

func (c *RestClient) SetHTTPClient(client *http.Client)

SetHTTPClient allows setting a custom HTTP client

type StaticTokenStore

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

StaticTokenStore implements TokenStore for static token authentication

func NewStaticTokenStore

func NewStaticTokenStore(tokenType, token string) *StaticTokenStore

NewStaticTokenStore creates a new static token store

func (*StaticTokenStore) GetToken

func (s *StaticTokenStore) GetToken() (string, string)

GetToken returns the stored token

func (*StaticTokenStore) SetToken

func (s *StaticTokenStore) SetToken(tokenType, token string)

SetToken updates the stored token

type TokenStore

type TokenStore interface {
	GetToken() (tokenType, token string)
}

TokenStore interface for managing authentication tokens

type Vanta

type Vanta interface {
	ListPeople(ctx context.Context, options *model.ListPeopleOptions) (*model.ListPeopleOutput, error)
	GetPersonByID(ctx context.Context, id string) (*model.Person, error)
	ListPolicies(ctx context.Context, options *model.ListPoliciesOptions) (*model.ListPoliciesOutput, error)
	GetPolicyByID(ctx context.Context, id string) (*model.PolicyItem, error)
	ListGroups(ctx context.Context, options *model.ListGroupsOptions) (*model.ListGroupsOutput, error)
	GetGroupByID(ctx context.Context, id string) (*model.GroupItem, error)
	ListConnectedIntegrations(ctx context.Context, options *model.ListIntegrationsOptions) (*model.ListIntegrationsOutput, error)
	GetIntegrationByID(ctx context.Context, id string) (*model.Integration, error)
	ListComputers(ctx context.Context, options *model.ListComputersOptions) (*model.ListComputersOutput, error)
	GetComputerByID(ctx context.Context, id string) (*model.Computer, error)
	ListVendors(ctx context.Context, options *model.ListVendorsOptions) (*model.ListVendorsOutput, error)
	GetVendorByID(ctx context.Context, id string) (*model.Vendor, error)
	ListMonitors(ctx context.Context, options *model.ListMonitorsOptions) (*model.MonitorResults, error)
	GetMonitorByID(ctx context.Context, id string) (*model.Monitor, error)
	ListTestEntities(ctx context.Context, testID string, options *model.ListTestEntitiesOptions) (*model.TestEntitiesResults, error)

	// Comprehensive Test API methods
	ListTests(ctx context.Context, options *model.ListTestsOptions) (*model.TestResults, error)
	GetTestByID(ctx context.Context, id string) (*model.Test, error)

	// Evidence API methods
	ListEvidence(ctx context.Context, auditID string, options *model.ListEvidenceOptions) (*model.ListEvidenceOutput, error)

	// Vulnerability API methods
	ListVulnerabilities(ctx context.Context, options *model.ListVulnerabilitiesOptions) (*model.ListVulnerabilitiesOutput, error)
	GetVulnerabilityByID(ctx context.Context, id string) (*model.Vulnerability, error)

	SetHTTPClient(client *http.Client)
}

Vanta interface defines the methods available on the client

func New

func New(ctx context.Context, opts ...Option) (Vanta, error)

New creates a new Vanta client with the given options

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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