hubclient

package
v0.9.6 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

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

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 TraceHubClientError added in v0.9.5

func TraceHubClientError(old error) error

Types

type BearerTokenResponse added in v0.9.5

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

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) 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) 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) ForEachPage added in v0.9.5

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

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) 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) 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) HttpPutJSON added in v0.9.3

func (c *Client) HttpPutJSON(url string, data interface{}, contentType string, expectedStatusCode int) 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) SetTimeout added in v0.9.5

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

func (*Client) UpdateExternalExtension

func (c *Client) UpdateExternalExtension(extension *hubapi.ExternalExtension) 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) 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