api

package
v1.6.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2018 License: Apache-2.0 Imports: 56 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//ReplicationJobType ...
	ReplicationJobType = "replication"
	//ScanJobType ...
	ScanJobType = "scan"
)
View Source
const (
	// PriPC : count of private projects
	PriPC = "private_project_count"
	// PriRC : count of private repositories
	PriRC = "private_repo_count"
	// PubPC : count of public projects
	PubPC = "public_project_count"
	// PubRC : count of public repositories
	PubRC = "public_repo_count"
	// TPC : total count of projects
	TPC = "total_project_count"
	// TRC : total count of repositories
	TRC = "total_repo_count"
)

Variables

View Source
var ErrDuplicateProjectMember = errors.New("The project member specified already exist")

ErrDuplicateProjectMember ...

View Source
var ErrInvalidRole = errors.New("Failed to update project member, role is not in 1,2,3")

ErrInvalidRole ...

Functions

func AddProjectMember added in v1.6.0

func AddProjectMember(projectID int64, request models.MemberReq) (int, error)

AddProjectMember ...

func Init added in v1.6.0

func Init() error

Init related objects/configurations for the API controllers

func SyncRegistry

func SyncRegistry(pm promgr.ProjectManager) error

SyncRegistry syncs the repositories of registry with database.

Types

type BaseController

type BaseController struct {
	api.BaseAPI
	// SecurityCtx is the security context used to authN &authZ
	SecurityCtx security.Context
	// ProjectMgr is the project manager which abstracts the operations
	// related to projects
	ProjectMgr promgr.ProjectManager
}

BaseController ...

func (*BaseController) Prepare

func (b *BaseController) Prepare()

Prepare inits security context and project manager from request context

type ChartRepositoryAPI added in v1.6.0

type ChartRepositoryAPI struct {
	//The base controller to provide common utilities
	BaseController
	// contains filtered or unexported fields
}

ChartRepositoryAPI provides related API handlers for the chart repository APIs

func (*ChartRepositoryAPI) DeleteChartVersion added in v1.6.0

func (cra *ChartRepositoryAPI) DeleteChartVersion()

DeleteChartVersion handles DELETE /api/:repo/charts/:name/:version

func (*ChartRepositoryAPI) DownloadChart added in v1.6.0

func (cra *ChartRepositoryAPI) DownloadChart()

DownloadChart handles GET /:repo/charts/:filename

func (*ChartRepositoryAPI) GetChartVersion added in v1.6.0

func (cra *ChartRepositoryAPI) GetChartVersion()

GetChartVersion handles GET /api/:repo/charts/:name/:version

func (*ChartRepositoryAPI) GetHealthStatus added in v1.6.0

func (cra *ChartRepositoryAPI) GetHealthStatus()

GetHealthStatus handles GET /api/chartserver/health

func (*ChartRepositoryAPI) GetIndex added in v1.6.0

func (cra *ChartRepositoryAPI) GetIndex()

GetIndex handles GET /index.yaml

func (*ChartRepositoryAPI) GetIndexByRepo added in v1.6.0

func (cra *ChartRepositoryAPI) GetIndexByRepo()

GetIndexByRepo handles GET /:repo/index.yaml

func (*ChartRepositoryAPI) ListChartVersions added in v1.6.0

func (cra *ChartRepositoryAPI) ListChartVersions()

ListChartVersions GET /api/:repo/charts/:name

func (*ChartRepositoryAPI) ListCharts added in v1.6.0

func (cra *ChartRepositoryAPI) ListCharts()

ListCharts handles GET /api/:repo/charts

func (*ChartRepositoryAPI) Prepare added in v1.6.0

func (cra *ChartRepositoryAPI) Prepare()

Prepare something for the following actions

func (*ChartRepositoryAPI) UploadChartProvFile added in v1.6.0

func (cra *ChartRepositoryAPI) UploadChartProvFile()

UploadChartProvFile handles POST /api/:repo/prov

func (*ChartRepositoryAPI) UploadChartVersion added in v1.6.0

func (cra *ChartRepositoryAPI) UploadChartVersion()

UploadChartVersion handles POST /api/:repo/charts

type ConfigAPI

type ConfigAPI struct {
	BaseController
}

ConfigAPI ...

func (*ConfigAPI) Get

func (c *ConfigAPI) Get()

Get returns configurations

func (*ConfigAPI) Prepare

func (c *ConfigAPI) Prepare()

Prepare validates the user

func (*ConfigAPI) Put

func (c *ConfigAPI) Put()

Put updates configurations

func (*ConfigAPI) Reset

func (c *ConfigAPI) Reset()

Reset system configurations

type EmailAPI

type EmailAPI struct {
	BaseController
}

EmailAPI ...

func (*EmailAPI) Ping

func (e *EmailAPI) Ping()

Ping tests connection and authentication with email server

func (*EmailAPI) Prepare

func (e *EmailAPI) Prepare()

Prepare ...

type GCAPI added in v1.6.0

type GCAPI struct {
	BaseController
}

GCAPI handles request of harbor admin...

func (*GCAPI) Get added in v1.6.0

func (gc *GCAPI) Get()

Get gets GC schedule ...

func (*GCAPI) GetGC added in v1.6.0

func (gc *GCAPI) GetGC()

GetGC ...

func (*GCAPI) GetLog added in v1.6.0

func (gc *GCAPI) GetLog()

GetLog ...

func (*GCAPI) List added in v1.6.0

func (gc *GCAPI) List()

List ...

func (*GCAPI) Post added in v1.6.0

func (gc *GCAPI) Post()

Post ...

func (*GCAPI) Prepare added in v1.6.0

func (gc *GCAPI) Prepare()

Prepare validates the URL and parms, it needs the system admin permission.

func (*GCAPI) Put added in v1.6.0

func (gc *GCAPI) Put()

Put ...

type GeneralInfo

type GeneralInfo struct {
	WithNotary                  bool                             `json:"with_notary"`
	WithClair                   bool                             `json:"with_clair"`
	WithAdmiral                 bool                             `json:"with_admiral"`
	AdmiralEndpoint             string                           `json:"admiral_endpoint"`
	AuthMode                    string                           `json:"auth_mode"`
	RegistryURL                 string                           `json:"registry_url"`
	ProjectCreationRestrict     string                           `json:"project_creation_restriction"`
	SelfRegistration            bool                             `json:"self_registration"`
	HasCARoot                   bool                             `json:"has_ca_root"`
	HarborVersion               string                           `json:"harbor_version"`
	NextScanAll                 int64                            `json:"next_scan_all"`
	ClairVulnStatus             *models.ClairVulnerabilityStatus `json:"clair_vulnerability_status,omitempty"`
	RegistryStorageProviderName string                           `json:"registry_storage_provider_name"`
	ReadOnly                    bool                             `json:"read_only"`
	WithChartMuseum             bool                             `json:"with_chartmuseum"`
}

GeneralInfo wraps common systeminfo for anonymous request

type InternalAPI

type InternalAPI struct {
	BaseController
}

InternalAPI handles request of harbor admin...

func (*InternalAPI) Prepare

func (ia *InternalAPI) Prepare()

Prepare validates the URL and parms

func (*InternalAPI) RenameAdmin

func (ia *InternalAPI) RenameAdmin()

RenameAdmin we don't provide flexibility in this API, as this is a workaround.

func (*InternalAPI) SyncRegistry

func (ia *InternalAPI) SyncRegistry()

SyncRegistry ...

type LabelAPI added in v1.5.0

type LabelAPI struct {
	BaseController
	// contains filtered or unexported fields
}

LabelAPI handles requests for label management

func (*LabelAPI) Delete added in v1.5.0

func (l *LabelAPI) Delete()

Delete the label

func (*LabelAPI) Get added in v1.5.0

func (l *LabelAPI) Get()

Get the label specified by ID

func (*LabelAPI) List added in v1.5.0

func (l *LabelAPI) List()

List labels according to the query strings

func (*LabelAPI) ListResources added in v1.6.0

func (l *LabelAPI) ListResources()

ListResources lists the resources that the label is referenced by

func (*LabelAPI) Post added in v1.5.0

func (l *LabelAPI) Post()

Post creates a label

func (*LabelAPI) Prepare added in v1.5.0

func (l *LabelAPI) Prepare()

Prepare ...

func (*LabelAPI) Put added in v1.5.0

func (l *LabelAPI) Put()

Put updates the label

type LdapAPI

type LdapAPI struct {
	BaseController
	// contains filtered or unexported fields
}

LdapAPI handles requesst to /api/ldap/ping /api/ldap/user/search /api/ldap/user/import

func (*LdapAPI) ImportUser

func (l *LdapAPI) ImportUser()

ImportUser ...

func (*LdapAPI) Ping

func (l *LdapAPI) Ping()

Ping ...

func (*LdapAPI) Prepare

func (l *LdapAPI) Prepare()

Prepare ...

func (*LdapAPI) Search

func (l *LdapAPI) Search()

Search ...

func (*LdapAPI) SearchGroup added in v1.5.0

func (l *LdapAPI) SearchGroup()

SearchGroup ... Search LDAP by groupname

type LogAPI

type LogAPI struct {
	BaseController
	// contains filtered or unexported fields
}

LogAPI handles request api/logs

func (*LogAPI) Get

func (l *LogAPI) Get()

Get returns the recent logs according to parameters

func (*LogAPI) Prepare

func (l *LogAPI) Prepare()

Prepare validates the URL and the user

type MetadataAPI

type MetadataAPI struct {
	BaseController
	// contains filtered or unexported fields
}

MetadataAPI ...

func (*MetadataAPI) Delete

func (m *MetadataAPI) Delete()

Delete ...

func (*MetadataAPI) Get

func (m *MetadataAPI) Get()

Get ...

func (*MetadataAPI) Post

func (m *MetadataAPI) Post()

Post ...

func (*MetadataAPI) Prepare

func (m *MetadataAPI) Prepare()

Prepare ...

func (*MetadataAPI) Put

func (m *MetadataAPI) Put()

Put ...

type ProjectAPI

type ProjectAPI struct {
	BaseController
	// contains filtered or unexported fields
}

ProjectAPI handles request to /api/projects/{} /api/projects/{}/logs

func (*ProjectAPI) Deletable

func (p *ProjectAPI) Deletable()

Deletable ...

func (*ProjectAPI) Delete

func (p *ProjectAPI) Delete()

Delete ...

func (*ProjectAPI) Get

func (p *ProjectAPI) Get()

Get ...

func (*ProjectAPI) Head

func (p *ProjectAPI) Head()

Head ...

func (*ProjectAPI) List

func (p *ProjectAPI) List()

List ...

func (*ProjectAPI) Logs

func (p *ProjectAPI) Logs()

Logs ...

func (*ProjectAPI) Post

func (p *ProjectAPI) Post()

Post ...

func (*ProjectAPI) Prepare

func (p *ProjectAPI) Prepare()

Prepare validates the URL and the user

func (*ProjectAPI) Put

func (p *ProjectAPI) Put()

Put ...

type ProjectMemberAPI

type ProjectMemberAPI struct {
	BaseController
	// contains filtered or unexported fields
}

ProjectMemberAPI handles request to /api/projects/{}/members/{}

func (*ProjectMemberAPI) Delete

func (pma *ProjectMemberAPI) Delete()

Delete ...

func (*ProjectMemberAPI) Get

func (pma *ProjectMemberAPI) Get()

Get ...

func (*ProjectMemberAPI) Post

func (pma *ProjectMemberAPI) Post()

Post ... Add a project member

func (*ProjectMemberAPI) Prepare

func (pma *ProjectMemberAPI) Prepare()

Prepare validates the URL and parms

func (*ProjectMemberAPI) Put

func (pma *ProjectMemberAPI) Put()

Put ... Update an exist project member

type RepJobAPI

type RepJobAPI struct {
	BaseController
	// contains filtered or unexported fields
}

RepJobAPI handles request to /api/replicationJobs /api/replicationJobs/:id/log

func (*RepJobAPI) Delete

func (ra *RepJobAPI) Delete()

Delete ...

func (*RepJobAPI) GetLog

func (ra *RepJobAPI) GetLog()

GetLog ...

func (*RepJobAPI) List

func (ra *RepJobAPI) List()

List filters jobs according to the parameters

func (*RepJobAPI) Prepare

func (ra *RepJobAPI) Prepare()

Prepare validates that whether user has system admin role

func (*RepJobAPI) StopJobs

func (ra *RepJobAPI) StopJobs()

StopJobs stop replication jobs for the policy

type RepPolicyAPI

type RepPolicyAPI struct {
	BaseController
}

RepPolicyAPI handles /api/replicationPolicies /api/replicationPolicies/:id/enablement

func (*RepPolicyAPI) Delete

func (pa *RepPolicyAPI) Delete()

Delete the replication policy

func (*RepPolicyAPI) Get

func (pa *RepPolicyAPI) Get()

Get ...

func (*RepPolicyAPI) List

func (pa *RepPolicyAPI) List()

List ...

func (*RepPolicyAPI) Post

func (pa *RepPolicyAPI) Post()

Post creates a replicartion policy

func (*RepPolicyAPI) Prepare

func (pa *RepPolicyAPI) Prepare()

Prepare validates whether the user has system admin role

func (*RepPolicyAPI) Put

func (pa *RepPolicyAPI) Put()

Put updates the replication policy

type ReplicationAPI

type ReplicationAPI struct {
	BaseController
}

ReplicationAPI handles API calls for replication

func (*ReplicationAPI) Post

func (r *ReplicationAPI) Post()

Post trigger a replication according to the specified policy

func (*ReplicationAPI) Prepare

func (r *ReplicationAPI) Prepare()

Prepare does authentication and authorization works

type RepositoryAPI

type RepositoryAPI struct {
	BaseController
}

RepositoryAPI handles request to /api/repositories /api/repositories/tags /api/repositories/manifests, the parm has to be put in the query string as the web framework can not parse the URL if it contains veriadic sectors.

func (*RepositoryAPI) Delete

func (ra *RepositoryAPI) Delete()

Delete ...

func (*RepositoryAPI) Get

func (ra *RepositoryAPI) Get()

Get ...

func (*RepositoryAPI) GetManifests

func (ra *RepositoryAPI) GetManifests()

GetManifests returns the manifest of a tag

func (*RepositoryAPI) GetSignatures

func (ra *RepositoryAPI) GetSignatures()

GetSignatures returns signatures of a repository

func (*RepositoryAPI) GetTag

func (ra *RepositoryAPI) GetTag()

GetTag returns the tag of a repository

func (*RepositoryAPI) GetTags

func (ra *RepositoryAPI) GetTags()

GetTags returns tags of a repository

func (*RepositoryAPI) GetTopRepos

func (ra *RepositoryAPI) GetTopRepos()

GetTopRepos returns the most populor repositories

func (*RepositoryAPI) Put

func (ra *RepositoryAPI) Put()

Put updates description info for the repository

func (*RepositoryAPI) ScanAll

func (ra *RepositoryAPI) ScanAll()

ScanAll handles the api to scan all images on Harbor.

func (*RepositoryAPI) ScanImage

func (ra *RepositoryAPI) ScanImage()

ScanImage handles request POST /api/repository/$repository/tags/$tag/scan to trigger image scan manually.

func (*RepositoryAPI) VulnerabilityDetails

func (ra *RepositoryAPI) VulnerabilityDetails()

VulnerabilityDetails fetch vulnerability info from clair, transform to Harbor's format and return to client.

type RepositoryLabelAPI added in v1.5.0

type RepositoryLabelAPI struct {
	BaseController
	// contains filtered or unexported fields
}

RepositoryLabelAPI handles requests for adding/removing label to/from repositories and images

func (*RepositoryLabelAPI) AddToImage added in v1.5.0

func (r *RepositoryLabelAPI) AddToImage()

AddToImage adds the label to an image

func (*RepositoryLabelAPI) AddToRepository added in v1.5.0

func (r *RepositoryLabelAPI) AddToRepository()

AddToRepository adds the label to a repository

func (*RepositoryLabelAPI) GetOfImage added in v1.5.0

func (r *RepositoryLabelAPI) GetOfImage()

GetOfImage returns labels of an image

func (*RepositoryLabelAPI) GetOfRepository added in v1.5.0

func (r *RepositoryLabelAPI) GetOfRepository()

GetOfRepository returns labels of a repository

func (*RepositoryLabelAPI) Prepare added in v1.5.0

func (r *RepositoryLabelAPI) Prepare()

Prepare ...

func (*RepositoryLabelAPI) RemoveFromImage added in v1.5.0

func (r *RepositoryLabelAPI) RemoveFromImage()

RemoveFromImage removes the label from an image

func (*RepositoryLabelAPI) RemoveFromRepository added in v1.5.0

func (r *RepositoryLabelAPI) RemoveFromRepository()

RemoveFromRepository removes the label from a repository

type ScanJobAPI

type ScanJobAPI struct {
	BaseController
	// contains filtered or unexported fields
}

ScanJobAPI handles request to /api/scanJobs/:id/log

func (*ScanJobAPI) GetLog

func (sj *ScanJobAPI) GetLog()

GetLog ...

func (*ScanJobAPI) Prepare

func (sj *ScanJobAPI) Prepare()

Prepare validates that whether user has read permission to the project of the repo the scan job scanned.

type SearchAPI

type SearchAPI struct {
	BaseController
}

SearchAPI handles requesst to /api/search

func (*SearchAPI) Get

func (s *SearchAPI) Get()

Get ...

type StatisticAPI

type StatisticAPI struct {
	BaseController
	// contains filtered or unexported fields
}

StatisticAPI handles request to /api/statistics/

func (*StatisticAPI) Get

func (s *StatisticAPI) Get()

Get total projects and repos of the user

func (*StatisticAPI) Prepare

func (s *StatisticAPI) Prepare()

Prepare validates the URL and the user

type Storage

type Storage struct {
	Total uint64 `json:"total"`
	Free  uint64 `json:"free"`
}

Storage models for storage.

type SystemInfo

type SystemInfo struct {
	HarborStorage Storage `json:"storage"`
}

SystemInfo models for system info.

type SystemInfoAPI

type SystemInfoAPI struct {
	BaseController
}

SystemInfoAPI handle requests for getting system info /api/systeminfo

func (*SystemInfoAPI) GetCert

func (sia *SystemInfoAPI) GetCert()

GetCert gets default self-signed certificate.

func (*SystemInfoAPI) GetGeneralInfo

func (sia *SystemInfoAPI) GetGeneralInfo()

GetGeneralInfo returns the general system info, which is to be called by anonymous user

func (*SystemInfoAPI) GetVolumeInfo

func (sia *SystemInfoAPI) GetVolumeInfo()

GetVolumeInfo gets specific volume storage info.

func (*SystemInfoAPI) Ping added in v1.5.0

func (sia *SystemInfoAPI) Ping()

Ping ping the harbor UI service.

type TargetAPI

type TargetAPI struct {
	BaseController
	// contains filtered or unexported fields
}

TargetAPI handles request to /api/targets/ping /api/targets/{}

func (*TargetAPI) Delete

func (t *TargetAPI) Delete()

Delete ...

func (*TargetAPI) Get

func (t *TargetAPI) Get()

Get ...

func (*TargetAPI) List

func (t *TargetAPI) List()

List ...

func (*TargetAPI) ListPolicies

func (t *TargetAPI) ListPolicies()

ListPolicies ...

func (*TargetAPI) Ping

func (t *TargetAPI) Ping()

Ping validates whether the target is reachable and whether the credential is valid

func (*TargetAPI) Post

func (t *TargetAPI) Post()

Post ...

func (*TargetAPI) Prepare

func (t *TargetAPI) Prepare()

Prepare validates the user

func (*TargetAPI) Put

func (t *TargetAPI) Put()

Put ...

type UserAPI

type UserAPI struct {
	BaseController

	SelfRegistration bool
	IsAdmin          bool
	AuthMode         string
	// contains filtered or unexported fields
}

UserAPI handles request to /api/users/{}

func (*UserAPI) ChangePassword

func (ua *UserAPI) ChangePassword()

ChangePassword handles PUT to /api/users/{}/password

func (*UserAPI) Delete

func (ua *UserAPI) Delete()

Delete ...

func (*UserAPI) Get

func (ua *UserAPI) Get()

Get ...

func (*UserAPI) List

func (ua *UserAPI) List()

List ...

func (*UserAPI) Post

func (ua *UserAPI) Post()

Post ...

func (*UserAPI) Prepare

func (ua *UserAPI) Prepare()

Prepare validates the URL and parms

func (*UserAPI) Put

func (ua *UserAPI) Put()

Put ...

func (*UserAPI) ToggleUserAdminRole

func (ua *UserAPI) ToggleUserAdminRole()

ToggleUserAdminRole handles PUT api/users/{}/sysadmin

type UserGroupAPI added in v1.5.0

type UserGroupAPI struct {
	BaseController
	// contains filtered or unexported fields
}

UserGroupAPI ...

func (*UserGroupAPI) Delete added in v1.5.0

func (uga *UserGroupAPI) Delete()

Delete ...

func (*UserGroupAPI) Get added in v1.5.0

func (uga *UserGroupAPI) Get()

Get ...

func (*UserGroupAPI) Post added in v1.5.0

func (uga *UserGroupAPI) Post()

Post ... Create User Group

func (*UserGroupAPI) Prepare added in v1.5.0

func (uga *UserGroupAPI) Prepare()

Prepare validates the URL and parms

func (*UserGroupAPI) Put added in v1.5.0

func (uga *UserGroupAPI) Put()

Put ... Only support update name

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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