Documentation ¶
Overview ¶
Package librariesio is a client library for accessing the libraries.io API.
Index ¶
- func Bool(b bool) *bool
- func CheckResponse(resp *http.Response) error
- func Int(i int) *int
- func String(s string) *string
- func Time(t time.Time) *time.Time
- type Client
- func (c *Client) Do(ctx context.Context, req *http.Request, obj interface{}) (*http.Response, error)
- func (c *Client) NewRequest(method, urlStr string, data interface{}) (*http.Request, error)
- func (c *Client) Project(ctx context.Context, plat, name string) (*Project, *http.Response, error)
- func (c *Client) ProjectDeps(ctx context.Context, plat, name, ver string) (*Project, *http.Response, error)
- func (c *Client) Search(ctx context.Context, q string) ([]*Project, *http.Response, error)
- func (c *Client) User(ctx context.Context, login string) (*User, *http.Response, error)
- func (c *Client) UserProjects(ctx context.Context, login string) ([]*Project, *http.Response, error)
- func (c *Client) UserRepositories(ctx context.Context, login string) ([]*Repository, *http.Response, error)
- type ErrorResponse
- type Project
- type ProjectDependency
- type Release
- type Repository
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckResponse ¶
CheckResponse checks the API response for errors and returns a ErrorResponse Responses are considered unsuccessful for status code other than 2xx.
Types ¶
type Client ¶
Client for communicating with the libraries.io API
func (*Client) Do ¶
func (c *Client) Do(ctx context.Context, req *http.Request, obj interface{}) (*http.Response, error)
Do sends an HTTP request, that can be cancelled via the given context. It makes sure to redact the API secret key from any URL errors and load the body from the HTTP response into the given obj and return the response.
func (*Client) NewRequest ¶
NewRequest creates a new API request, that can be used for client.Do(). It creates an absolute URL from the given URL string and serialize the given payload, set the according headers and add the api_key query param.
func (*Client) Project ¶
Project returns information about a project and it's versions.
GET https://libraries.io/api/:platform/:name
plat is the platform/package manager of the project name is the name of the project on the platform
func (*Client) ProjectDeps ¶
func (c *Client) ProjectDeps(ctx context.Context, plat, name, ver string) (*Project, *http.Response, error)
ProjectDeps returns information about a project and it's dependencies.
GET https://libraries.io/api/:platform/:name/:version/dependencies
plat is the platform/package manager of the project name is the name of the project on the platform ver is the version of the project - pass "latest" for current release
func (*Client) User ¶
User returns information for a given user or organization
GET https://libraries.io/api/github/:login
login is a user or organization on GitHub
func (*Client) UserProjects ¶
func (c *Client) UserProjects(ctx context.Context, login string) ([]*Project, *http.Response, error)
UserProjects returns projects referencing the given GitHub user
GET https://libraries.io/api/github/:login/projects
login is a user or organization on GitHub
func (*Client) UserRepositories ¶
func (c *Client) UserRepositories(ctx context.Context, login string) ([]*Repository, *http.Response, error)
UserRepositories returns repositories owned by the given GitHub user
GET https://libraries.io/api/github/:login/repositories
login is a user or organization on GitHub
type ErrorResponse ¶
ErrorResponse holds information about an unsuccessful API request. The error message from the API response is stored to the Message field.
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
Error returns information about the ErrorResponse
type Project ¶
type Project struct { Description *string `json:"description,omitempty"` Forks *int `json:"forks,omitempty"` Homepage *string `json:"homepage,omitempty"` Keywords []*string `json:"keywords,omitempty"` Language *string `json:"language,omitempty"` LatestReleaseNumber *string `json:"latest_release_number,omitempty"` LatestReleasePublishedAt *time.Time `json:"latest_release_published_at,omitempty"` LatestStableRelease *Release `json:"latest_stable_release,omitempty"` Name *string `json:"name,omitempty"` NormalizedLicenses []*string `json:"normalized_licenses,omitempty"` PackageManagerURL *string `json:"package_manager_url,omitempty"` Platform *string `json:"platform,omitempty"` Rank *int `json:"rank,omitempty"` Stars *int `json:"stars,omitempty"` Status *string `json:"status,omitempty"` Versions []*Release `json:"versions,omitempty"` // Dependencies are only populated for ProjectDeps Dependencies []*ProjectDependency `json:"dependencies,omitempty"` // RepositoryURL is only populated for UserProjects RepositoryURL *string `json:"repository_url,omitempty"` }
Project represents a project on libraries.io
type ProjectDependency ¶
type ProjectDependency struct { Deprecated *bool `json:"deprecated,omitempty"` Latest *string `json:"latest,omitempty"` LatestStable *string `json:"latest_stable,omitempty"` Name *string `json:"name,omitempty"` Outdated *bool `json:"outdated,omitempty"` Platform *string `json:"platform,omitempty"` ProjectName *string `json:"project_name,omitempty"` Requirements *string `json:"requirements,omitempty"` }
ProjectDependency represents a dependency of the project
type Release ¶
type Release struct { Number *string `json:"number,omitempty"` PublishedAt *time.Time `json:"published_at,omitempty"` }
Release represents a release of the project
type Repository ¶
type Repository struct { ContributionsCount *int `json:"contributions_count,omitempty"` CreatedAt *time.Time `json:"created_at,omitempty"` DefaultBranch *string `json:"default_branch,omitempty"` Description *string `json:"description,omitempty"` Fork *bool `json:"fork,omitempty"` ForkPolicy *string `json:"fork_policy,omitempty"` ForksCount *int `json:"forks_count,omitempty"` FullName *string `json:"full_name,omitempty"` GithubContributionsCount *int `json:"github_contributions_count,omitempty"` GithubID *string `json:"github_id,omitempty"` HasAudit *string `json:"has_audit,omitempty"` HasChangelog *string `json:"has_changelog,omitempty"` HasCoc *string `json:"has_coc,omitempty"` HasContributing *string `json:"has_contributing,omitempty"` HasIssues *bool `json:"has_issues,omitempty"` HasLicense *string `json:"has_license,omitempty"` HasPages *bool `json:"has_pages,omitempty"` HasReadme *string `json:"has_readme,omitempty"` HasThreatModel *string `json:"has_threat_model,omitempty"` HasWiki *bool `json:"has_wiki,omitempty"` Homepage *string `json:"homepage,omitempty"` HostDomain *string `json:"host_domain,omitempty"` HostType *string `json:"host_type,omitempty"` Keywords []*string `json:"keywords,omitempty"` Language *string `json:"language,omitempty"` LastSyncedAt *time.Time `json:"last_synced_at,omitempty"` License *string `json:"license,omitempty"` LogoURL *string `json:"logo_url,omitempty"` MirrorURL *string `json:"mirror_url,omitempty"` Name *string `json:"name,omitempty"` OpenIssuesCount *int `json:"open_issues_count,omitempty"` Private *bool `json:"private,omitempty"` PullRequestsEnabled *bool `json:"pull_requests_enabled,omitempty"` PushedAt *time.Time `json:"pushed_at,omitempty"` Rank *int `json:"rank,omitempty"` Scm *string `json:"scm,omitempty"` Size *int `json:"size,omitempty"` SourceName *string `json:"source_name,omitempty"` StargazersCount *int `json:"stargazers_count,omitempty"` Status *string `json:"status,omitempty"` SubscribersCount *int `json:"subscribers_count,omitempty"` UUID *string `json:"uuid,omitempty"` UpdatedAt *time.Time `json:"updated_at,omitempty"` }
Repository represents a GitHub project
type User ¶
type User struct { ID *int `json:"id,omitempty"` UUID *int `json:"uuid,omitempty"` Login *string `json:"login,omitempty"` UserType *string `json:"user_type,omitempty"` CreatedAt *time.Time `json:"created_at,omitempty"` UpdatedAt *time.Time `json:"updated_at,omitempty"` Name *string `json:"name,omitempty"` Company *string `json:"company,omitempty"` Blog *string `json:"blog,omitempty"` Location *string `json:"location,omitempty"` Hidden *bool `json:"hidden,omitempty"` LastSyncedAt *time.Time `json:"last_synced_at,omitempty"` Email *string `json:"email,omitempty"` Bio *string `json:"bio,omitempty"` Followers *int `json:"followers,omitempty"` Following *int `json:"following,omitempty"` HostType *string `json:"host_type,omitempty"` GitHubID *int `json:"github_id,omitempty"` }
User represents a user on libraries.io