hubclient

package
v0.9.11 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2023 License: Apache-2.0 Imports: 19 Imported by: 7

Documentation

Index

Constants

View Source
const (
	HeaderNameContentType   = "Content-Type"
	HeaderNameAccept        = "Accept"
	HeaderNameAuthorization = "Authorization"
	HeaderNameCsrfToken     = "X-Csrf-Token"
	HeaderNameUserAgent     = "User-Agent"
)

Variables

This section is empty.

Functions

func AnnotateHubClientError added in v0.9.5

func AnnotateHubClientError(old error, format string) error

func AnnotateHubClientErrorf added in v0.9.5

func AnnotateHubClientErrorf(old error, format string, args ...interface{}) error

func HubClientErrorf added in v0.9.5

func HubClientErrorf(format string, args ...interface{}) error

func HubClientStatusCodeErrorf added in v0.9.7

func HubClientStatusCodeErrorf(statusCode int, format string, args ...interface{}) error

func TraceHubClientError added in v0.9.5

func TraceHubClientError(old error) error

Types

type ArrayChunkIterator added in v0.9.11

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

func NewArrayChunkIterator added in v0.9.11

func NewArrayChunkIterator(chunks []string) ArrayChunkIterator

func (*ArrayChunkIterator) HasNext added in v0.9.11

func (i *ArrayChunkIterator) HasNext() bool

func (*ArrayChunkIterator) Next added in v0.9.11

func (i *ArrayChunkIterator) Next() (string, error)

Next returns true and the next chunk if there is a next chunk. Returns false otherwise.

type BearerTokenResponse added in v0.9.5

type BearerTokenResponse struct {
	BearerToken           string `json:"bearerToken"`
	ExpiresInMilliseconds int64  `json:"expiresInMilliseconds"`
}

type ChunkIterator added in v0.9.11

type ChunkIterator interface {
	HasNext() bool
	Next() (string, error)
}

type Client

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

Client will need to support CSRF tokens for session-based auth for Hub 4.1.x (or was it 4.0?)

func NewWithApiToken added in v0.9.5

func NewWithApiToken(baseURL string, apiToken string, debugFlags HubClientDebug, timeout time.Duration) (*Client, error)

func NewWithApiTokenAndClient added in v0.9.5

func NewWithApiTokenAndClient(baseURL string, apiToken string, debugFlags HubClientDebug, client *http.Client) (*Client, error)

func NewWithClient added in v0.9.5

func NewWithClient(baseURL string, debugFlags HubClientDebug, httpClient *http.Client) (*Client, error)

func NewWithSession

func NewWithSession(baseURL string, debugFlags HubClientDebug, timeout time.Duration) (*Client, error)

func NewWithToken

func NewWithToken(baseURL string, authToken string, debugFlags HubClientDebug, timeout time.Duration) (*Client, error)

func NewWithTokenAndClient added in v0.9.5

func NewWithTokenAndClient(baseURL string, authToken string, debugFlags HubClientDebug, httpClient *http.Client) (*Client, error)

func (*Client) AssignUserToProject added in v0.9.3

func (c *Client) AssignUserToProject(link hubapi.ResourceLink, userAssignmentRequest *hubapi.UserAssignmentRequest) (string, error)

func (*Client) BaseURL added in v0.9.4

func (c *Client) BaseURL() string

func (*Client) CheckHubLiveness added in v0.9.8

func (c *Client) CheckHubLiveness() (error, *hubapi.HealthCheckStatus)

func (*Client) CheckHubReadiness added in v0.9.8

func (c *Client) CheckHubReadiness() (error, *hubapi.HealthCheckStatus)

func (*Client) Count added in v0.9.5

func (c *Client) Count(link string) (int, error)

func (*Client) CountProjectVersionVulnerableComponents

func (c *Client) CountProjectVersionVulnerableComponents(link hubapi.ResourceLink) (int, error)

func (*Client) CreateApiToken added in v0.9.5

func (c *Client) CreateApiToken(name, description string, readOnly bool) (location string, token string, err error)

func (*Client) CreateComponent added in v0.9.5

func (c *Client) CreateComponent(componentRequest *hubapi.ComponentRequest) (string, error)

func (*Client) CreatePolicyRule added in v0.9.5

func (c *Client) CreatePolicyRule(policyRuleRequest *hubapi.PolicyRuleRequest) (string, error)

func (*Client) CreateProject

func (c *Client) CreateProject(projectRequest *hubapi.ProjectRequest) (string, error)

func (*Client) CreateProjectVersion

func (c *Client) CreateProjectVersion(link hubapi.ResourceLink, projectVersionRequest *hubapi.ProjectVersionRequest) (string, error)

func (*Client) CreateUser added in v0.9.3

func (c *Client) CreateUser(userRequest *hubapi.UserRequest) (*hubapi.User, error)

TODO: This API should also be returning a location

func (*Client) CurrentVersion added in v0.9.1

func (c *Client) CurrentVersion() (*hubapi.CurrentVersion, error)

func (*Client) DeleteApiToken added in v0.9.5

func (c *Client) DeleteApiToken(tokenUrl string) error

func (*Client) DeleteCodeLocation added in v0.9.2

func (c *Client) DeleteCodeLocation(codeLocationURL string) error

DeleteCodeLocation deletes a code location using https://<base_hub_URL>/api.html#!/composite45code45location45rest45server/deleteCodeLocationUsingDELETE

func (*Client) DeleteComponent added in v0.9.5

func (c *Client) DeleteComponent(componentURL string) error

func (*Client) DeletePolicyRule added in v0.9.5

func (c *Client) DeletePolicyRule(policyRuleURL string) error

func (*Client) DeleteProject

func (c *Client) DeleteProject(projectURL string) error

func (*Client) DeleteProjectVersion added in v0.9.2

func (c *Client) DeleteProjectVersion(projectVersionURL string) error

DeleteProjectVersion deletes a project version using https://<base_hub_URL>/api.html#!/project45version45rest45server/deleteVersionUsingDELETE

func (*Client) DetectURI added in v0.9.7

func (c *Client) DetectURI() (*hubapi.DetectURI, error)

func (*Client) DownloadScanClientLinux added in v0.9.1

func (c *Client) DownloadScanClientLinux(path string) error

func (*Client) DownloadScanClientMac added in v0.9.1

func (c *Client) DownloadScanClientMac(path string) error

func (*Client) DownloadScanClientWindows added in v0.9.1

func (c *Client) DownloadScanClientWindows(path string) error

func (*Client) FetchResults added in v0.9.8

func (c *Client) FetchResults(rapidScanEndpoint string, offset int, pageLimit int) (err error, httpStatus int, result *hubapi.RapidScanResult)

func (*Client) ForEachPage added in v0.9.5

func (c *Client) ForEachPage(link string, listOptions *hubapi.GetListOptions, list interface{}, pageFunc func() error) (err error)

func (*Client) GetAuthTokenExpiryTime added in v0.9.8

func (c *Client) GetAuthTokenExpiryTime() int64

GetAuthTokenExpiryTime returns the unix time in seconds at which the cached auth token is set to expire This func returns -1 if the Client is not configured to use auth token

func (*Client) GetCodeLocation

func (c *Client) GetCodeLocation(link hubapi.ResourceLink) (*hubapi.CodeLocation, error)

func (*Client) GetComponent added in v0.9.5

func (c *Client) GetComponent(link hubapi.ResourceLink) (*hubapi.Component, error)

func (*Client) GetComponentVersion added in v0.9.5

func (c *Client) GetComponentVersion(link hubapi.ResourceLink) (*hubapi.ComponentVersion, error)

func (*Client) GetComponentVersionRemediation added in v0.9.5

func (c *Client) GetComponentVersionRemediation(componentVersionHref string) (*hubapi.ComponentRemediation, error)

func (*Client) GetCurrentUser added in v0.9.5

func (c *Client) GetCurrentUser() (response *hubapi.CurrentUserResponse, err error)

func (*Client) GetExternalExtension

func (c *Client) GetExternalExtension(link hubapi.ResourceLink) (*hubapi.ExternalExtension, error)

func (*Client) GetPage added in v0.9.5

func (c *Client) GetPage(link string, options *hubapi.GetListOptions, list interface{}) error

func (*Client) GetPolicyRule added in v0.9.5

func (c *Client) GetPolicyRule(link hubapi.ResourceLink) (*hubapi.PolicyRule, error)

func (*Client) GetProject

func (c *Client) GetProject(link hubapi.ResourceLink) (*hubapi.Project, error)

func (*Client) GetProjectVersion

func (c *Client) GetProjectVersion(link hubapi.ResourceLink) (*hubapi.ProjectVersion, error)

func (*Client) GetProjectVersionPolicyStatus

func (c *Client) GetProjectVersionPolicyStatus(link hubapi.ResourceLink) (*hubapi.ProjectVersionPolicyStatus, error)

func (*Client) GetProjectVersionRiskProfile

func (c *Client) GetProjectVersionRiskProfile(link hubapi.ResourceLink) (*hubapi.ProjectVersionRiskProfile, error)

func (*Client) GetScanSummary

func (c *Client) GetScanSummary(link hubapi.ResourceLink) (*hubapi.ScanSummary, error)

func (*Client) GetUpgradeGuidanceForComponent added in v0.9.8

func (c *Client) GetUpgradeGuidanceForComponent(componentVariant hubapi.ComponentVariant) (*hubapi.ComponentUpgradeGuidance, error)

func (*Client) GetUpgradeGuidanceForComponentVersion added in v0.9.8

func (c *Client) GetUpgradeGuidanceForComponentVersion(componentVersion *hubapi.ComponentVersion) (*hubapi.ComponentUpgradeGuidance, error)

func (*Client) GetUser added in v0.9.5

func (c *Client) GetUser(link hubapi.ResourceLink) (*hubapi.User, error)

func (*Client) GetVulnerability added in v0.9.5

func (c *Client) GetVulnerability(link hubapi.ResourceLink) (*hubapi.Vulnerability, error)

func (*Client) HttpDelete added in v0.9.3

func (c *Client) HttpDelete(url string, contentType string, expectedStatusCode int) error

func (*Client) HttpGetJSON added in v0.9.3

func (c *Client) HttpGetJSON(url string, result interface{}, expectedStatusCode int, mimetypes ...string) error

func (*Client) HttpGetString added in v0.9.7

func (c *Client) HttpGetString(url string, result *string, expectedStatusCode []int, mimetypes ...string) (error, int)

func (*Client) HttpPostFile added in v0.9.8

func (c *Client) HttpPostFile(url string, filePath string, contentType string) (string, int, error)

func (*Client) HttpPostJSON added in v0.9.3

func (c *Client) HttpPostJSON(url string, data interface{}, contentType string, expectedStatusCode int) (string, error)

func (*Client) HttpPostJSONExpectResult added in v0.9.3

func (c *Client) HttpPostJSONExpectResult(url string, data interface{}, result interface{}, contentType string, expectedStatusCode int) (string, error)

func (*Client) HttpPostString added in v0.9.7

func (c *Client) HttpPostString(url string, data string, contentType string, expectedStatusCode int) (string, error)

func (*Client) HttpPutJSON added in v0.9.3

func (c *Client) HttpPutJSON(url string, data interface{}, contentType string, expectedStatusCode int) error

func (*Client) HttpPutString added in v0.9.7

func (c *Client) HttpPutString(url string, data string, contentType string, expectedStatusCode int) error

func (*Client) HttpPutStringWithHeader added in v0.9.8

func (c *Client) HttpPutStringWithHeader(url string, data string, contentType string, expectedStatusCode int, header http.Header) error

func (*Client) ListAllCodeLocations added in v0.9.5

func (c *Client) ListAllCodeLocations(options *hubapi.GetListOptions) (*hubapi.CodeLocationList, error)

func (*Client) ListAllComponents added in v0.9.5

func (c *Client) ListAllComponents(options *hubapi.GetListOptions) (*hubapi.ComponentList, error)

func (*Client) ListAllProjectVersionVulnerableComponents

func (c *Client) ListAllProjectVersionVulnerableComponents(link hubapi.ResourceLink) ([]hubapi.BomVulnerableComponent, error)

func (*Client) ListApiTokens added in v0.9.5

func (c *Client) ListApiTokens(options *hubapi.GetListOptions) (*hubapi.ApiTokenList, error)

func (*Client) ListCodeLocations

func (c *Client) ListCodeLocations(link hubapi.ResourceLink, options *hubapi.GetListOptions) (*hubapi.CodeLocationList, error)

func (*Client) ListComponents added in v0.9.5

func (c *Client) ListComponents(options *hubapi.GetListOptions) (*hubapi.ComponentList, error)

func (*Client) ListPolicyRules added in v0.9.5

func (c *Client) ListPolicyRules(options *hubapi.GetListOptions) (*hubapi.PolicyRuleList, error)

func (*Client) ListProjectVersionComponents

func (c *Client) ListProjectVersionComponents(link hubapi.ResourceLink) (*hubapi.BomComponentList, error)

func (*Client) ListProjectVersionVulnerableComponents

func (c *Client) ListProjectVersionVulnerableComponents(link hubapi.ResourceLink) (*hubapi.BomVulnerableComponentList, error)

TODO: Should this be used?

func (*Client) ListProjectVersions

func (c *Client) ListProjectVersions(link hubapi.ResourceLink, options *hubapi.GetListOptions) (*hubapi.ProjectVersionList, error)

func (*Client) ListProjects

func (c *Client) ListProjects(options *hubapi.GetListOptions) (*hubapi.ProjectList, error)

What about continuation for these? Should we have something where user can pass in an optional continuation/next placeholder? Or maybe that is something more for RX? Or maybe a special return type that can keep querying for all of them when it runs out? Is there any iterator type in GoLang?

func (*Client) ListScanSummaries

func (c *Client) ListScanSummaries(link hubapi.ResourceLink) (*hubapi.ScanSummaryList, error)

func (*Client) ListUsers added in v0.9.3

func (c *Client) ListUsers(options *hubapi.GetListOptions) (*hubapi.UserList, error)

func (*Client) Login

func (c *Client) Login(username string, password string) error

func (*Client) PollRapidScanResults added in v0.9.7

func (c *Client) PollRapidScanResults(rapidScanEndpoint string, interval, timeout time.Duration, pageLimit int) (error, *hubapi.RapidScanResult)

func (*Client) SetBearerToken added in v0.9.9

func (c *Client) SetBearerToken(token string)

func (*Client) SetTimeout added in v0.9.5

func (c *Client) SetTimeout(timeout time.Duration)

func (*Client) SetUserAgent added in v0.9.8

func (c *Client) SetUserAgent(agent string)

Sets the User-Agent header value to be used in all http/https requests made by the client

func (*Client) SsoStatus added in v0.9.7

func (c *Client) SsoStatus() (*hubapi.SsoStatus, error)

func (*Client) StartRapidScan added in v0.9.7

func (c *Client) StartRapidScan(bdioHeaderContent string) (error, string)

func (*Client) UpdateExternalExtension

func (c *Client) UpdateExternalExtension(extension *hubapi.ExternalExtension) error

func (*Client) UploadBdioFiles added in v0.9.7

func (c *Client) UploadBdioFiles(bdioUploadEndpoint string, bdioContents []string) error

func (*Client) UploadBdioFilesByChunk added in v0.9.11

func (c *Client) UploadBdioFilesByChunk(bdioUploadEndpoint string, chunkCount int, iterator ChunkIterator) error

type HubClientDebug

type HubClientDebug uint16
const (
	HubClientDebugTimings HubClientDebug = 1 << iota
	HubClientDebugContent
)

type HubClientError added in v0.9.5

type HubClientError struct {
	Err        error
	StatusCode int
	HubError   HubResponseError
}

func (HubClientError) Cause added in v0.9.7

func (e HubClientError) Cause() error

func (HubClientError) Error added in v0.9.5

func (e HubClientError) Error() string

type HubResponseError added in v0.9.5

type HubResponseError struct {
	ErrorMessage string                   `json:"errorMessage"`
	Arguments    HubResponseErrorArgument `json:"arguments"`
	Errors       []HubResponseError       `json:"errors"`
	ErrorCode    string                   `json:"errorCode"`
}

type HubResponseErrorArgument added in v0.9.5

type HubResponseErrorArgument struct {
	FieldName    string `json:"fieldname"`
	Type         string `json:"type"`
	Message      string `json:"message"`
	InvalidValue string `json:"invalidValue"`
}

Jump to

Keyboard shortcuts

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