Help us shape the future of Go! Take the 2026 Go Developer Survey

hubclient

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OrgAccessTokenTypeRepo = "TYPE_REPO"
	OrgAccessTokenTypeOrg  = "TYPE_ORG"
)
View Source
const (
	TeamRepoPermissionLevelRead  = "read"
	TeamRepoPermissionLevelWrite = "write"
	TeamRepoPermissionLevelAdmin = "admin"
)
View Source
const ImmutableTagRulesSeparator = ","
View Source
const (
	StandardRegistryDocker = "DockerHub"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessToken

type AccessToken struct {
	UUID        string   `json:"uuid"`
	ClientID    string   `json:"client_id"`
	CreatorIP   string   `json:"creator_ip"`
	CreatorUA   string   `json:"creator_ua"`
	CreatedAt   string   `json:"created_at"`
	LastUsed    string   `json:"last_used"`
	GeneratedBy string   `json:"generated_by"`
	IsActive    bool     `json:"is_active"`
	Token       string   `json:"token"`
	TokenLabel  string   `json:"token_label"`
	Scopes      []string `json:"scopes"`
	ExpiresAt   string   `json:"expires_at,omitempty"`
}

type AccessTokenCreateParams

type AccessTokenCreateParams struct {
	TokenLabel string   `json:"token_label"`
	Scopes     []string `json:"scopes"`
	ExpiresAt  string   `json:"expires_at,omitempty"`
}

type AccessTokenPage

type AccessTokenPage struct {
	Count    int           `json:"count"`
	Next     interface{}   `json:"next,omitempty"`
	Previous interface{}   `json:"previous,omitempty"`
	Results  []AccessToken `json:"results"`
}

type AccessTokenUpdateParams

type AccessTokenUpdateParams struct {
	TokenLabel string `json:"token_label"`
	IsActive   bool   `json:"is_active"`
}

type Client

type Client struct {
	BaseURL    string
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

func NewClient

func NewClient(config Config) *Client

func (*Client) AddOrgTeamMember

func (c *Client) AddOrgTeamMember(ctx context.Context, orgName string, teamName string, userName string) error

func (*Client) CreateAccessToken

func (c *Client) CreateAccessToken(ctx context.Context, accessToken AccessTokenCreateParams) (AccessToken, error)

func (*Client) CreateOrgAccessToken added in v0.6.0

func (c *Client) CreateOrgAccessToken(ctx context.Context, orgName string, params OrgAccessTokenCreateParams) (OrgAccessToken, error)

func (*Client) CreateOrgTeam

func (c *Client) CreateOrgTeam(ctx context.Context, orgName string, createOrgTeam OrgTeam) (OrgTeam, error)

func (*Client) CreatePermissionForTeamAndRepo

func (c *Client) CreatePermissionForTeamAndRepo(ctx context.Context, repository string, teamID int64, permission string) (TeamRepoPermission, error)

func (*Client) CreateRepository

func (c *Client) CreateRepository(ctx context.Context, namespace string, req CreateRepositoryRequest) (Repository, error)

func (*Client) DeleteAccessToken

func (c *Client) DeleteAccessToken(ctx context.Context, accessTokenID string) error

func (*Client) DeleteOrgAccessToken added in v0.6.0

func (c *Client) DeleteOrgAccessToken(ctx context.Context, orgName, accessTokenID string) error

func (*Client) DeleteOrgInvite

func (c *Client) DeleteOrgInvite(ctx context.Context, inviteID string) error

func (*Client) DeleteOrgMember

func (c *Client) DeleteOrgMember(ctx context.Context, orgName string, userName string) error

func (*Client) DeleteOrgTeam

func (c *Client) DeleteOrgTeam(ctx context.Context, orgName string, teamName string) error

func (*Client) DeleteOrgTeamMember

func (c *Client) DeleteOrgTeamMember(ctx context.Context, orgName string, teamName string, userName string) error

func (*Client) DeletePermissionForTeamAndRepo

func (c *Client) DeletePermissionForTeamAndRepo(ctx context.Context, repository string, teamID int64) error

func (*Client) DeleteRepository

func (c *Client) DeleteRepository(ctx context.Context, id string) error

func (*Client) GetAccessToken

func (c *Client) GetAccessToken(ctx context.Context, accessTokenID string) (AccessToken, error)

func (*Client) GetAccessTokens

func (c *Client) GetAccessTokens(ctx context.Context) (AccessTokenPage, error)

func (*Client) GetOrg

func (c *Client) GetOrg(ctx context.Context, orgName string) (Org, error)

func (*Client) GetOrgAccessToken added in v0.6.0

func (c *Client) GetOrgAccessToken(ctx context.Context, orgName, accessTokenID string) (OrgAccessToken, error)

func (*Client) GetOrgSettingImageAccessManagement

func (c *Client) GetOrgSettingImageAccessManagement(ctx context.Context, orgName string) (OrgSettingImageAccessManagement, error)

func (*Client) GetOrgSettingRegistryAccessManagement

func (c *Client) GetOrgSettingRegistryAccessManagement(ctx context.Context, orgName string) (OrgSettingRegistryAccessManagement, error)

func (*Client) GetOrgSettings

func (c *Client) GetOrgSettings(ctx context.Context, orgName string) (Org, error)

func (*Client) GetOrgTeam

func (c *Client) GetOrgTeam(ctx context.Context, orgName string, teamName string) (OrgTeam, error)

func (*Client) GetPermissionForTeamAndRepo

func (c *Client) GetPermissionForTeamAndRepo(ctx context.Context, repository string, teamID int64) (TeamRepoPermission, error)

func (*Client) GetRepositories

func (c *Client) GetRepositories(ctx context.Context, namespace string) (Repositories, error)

func (*Client) GetRepository

func (c *Client) GetRepository(ctx context.Context, id string) (Repository, error)

func (*Client) GetRepositoryTag added in v0.5.0

func (c *Client) GetRepositoryTag(ctx context.Context, namespace string, repository string, tag string) (Tag, error)

func (*Client) GetRepositoryTags added in v0.5.0

func (c *Client) GetRepositoryTags(ctx context.Context, namespace, name string) (*Tags, error)

func (*Client) InviteOrgMember

func (c *Client) InviteOrgMember(ctx context.Context, orgName, role string, invitees []string, dryRun bool) (OrgInviteResponse, error)

func (*Client) ListOrgInvites added in v0.4.0

func (c *Client) ListOrgInvites(ctx context.Context, orgName string) ([]OrgInvite, error)

func (*Client) ListOrgMembers added in v0.4.0

func (c *Client) ListOrgMembers(ctx context.Context, orgName string) ([]OrgMember, error)

func (*Client) ListOrgTeamMembers

func (c *Client) ListOrgTeamMembers(ctx context.Context, orgName string, teamName string) ([]OrgTeamMember, error)

func (*Client) MaxPageResults added in v0.5.0

func (c *Client) MaxPageResults() int64

func (*Client) SetOrgSettingImageAccessManagement

func (c *Client) SetOrgSettingImageAccessManagement(ctx context.Context, orgName string, iamSettings OrgSettingImageAccessManagement) (OrgSettingImageAccessManagement, error)

func (*Client) SetOrgSettingRegistryAccessManagement

func (c *Client) SetOrgSettingRegistryAccessManagement(ctx context.Context, orgName string, reamSettings OrgSettingRegistryAccessManagement) (OrgSettingRegistryAccessManagement, error)

func (*Client) SetRepositoryPrivacy

func (c *Client) SetRepositoryPrivacy(ctx context.Context, id string, isPrivate bool) error

func (*Client) UpdateAccessToken

func (c *Client) UpdateAccessToken(ctx context.Context, accessTokenID string, accessTokenUpdate AccessTokenUpdateParams) (AccessToken, error)

func (*Client) UpdateOrgAccessToken added in v0.6.0

func (c *Client) UpdateOrgAccessToken(ctx context.Context, orgName, accessTokenID string, params OrgAccessTokenUpdateParams) (OrgAccessToken, error)

func (*Client) UpdateOrgMember added in v0.5.3

func (c *Client) UpdateOrgMember(ctx context.Context, orgName string, userName string, role OrgRoleParam) error

func (*Client) UpdateOrgTeam

func (c *Client) UpdateOrgTeam(ctx context.Context, orgName string, teamName string, updateOrgTeam OrgTeam) (OrgTeam, error)

func (*Client) UpdatePermissionForTeamAndRepo

func (c *Client) UpdatePermissionForTeamAndRepo(ctx context.Context, repository string, teamID int64, permission string) (TeamRepoPermission, error)

func (*Client) UpdateRepository

func (c *Client) UpdateRepository(ctx context.Context, id string, req UpdateRepositoryRequest) (Repository, error)

func (*Client) Username added in v0.3.1

func (c *Client) Username() string

type Config

type Config struct {
	BaseURL        string
	TokenProvider  TokenProvider
	Transport      http.RoundTripper
	MaxPageResults int64
}

type CreateRepositoryRequest added in v0.5.0

type CreateRepositoryRequest struct {
	Name            string `json:"name"`
	Description     string `json:"description"`
	FullDescription string `json:"full_description"`
	Registry        string `json:"registry"`
	IsPrivate       bool   `json:"is_private"`
}

type ImageAccessManagementRestrictedImages

type ImageAccessManagementRestrictedImages struct {
	Enabled                 bool `json:"enabled"`
	AllowOfficialImages     bool `json:"allow_official_images"`
	AllowVerifiedPublishers bool `json:"allow_verified_publishers"`
}

type ImmutableTagsSettings added in v0.5.0

type ImmutableTagsSettings struct {
	Enabled bool     `json:"enabled"`
	Rules   []string `json:"rules"`
}

type Org

type Org struct {
	ID         string `json:"id,omitempty"`
	OrgName    string `json:"orgname"`
	FullName   string `json:"full_name"`
	Location   string `json:"location"`
	Company    string `json:"company"`
	DateJoined string `json:"date_joined"`
}

type OrgAccessToken added in v0.6.0

type OrgAccessToken struct {
	ID          string                   `json:"id"`
	Label       string                   `json:"label"`
	Description string                   `json:"description,omitempty"`
	CreatedBy   string                   `json:"created_by"`
	IsActive    bool                     `json:"is_active"`
	CreatedAt   string                   `json:"created_at"`
	ExpiresAt   string                   `json:"expires_at,omitempty"`
	LastUsedAt  string                   `json:"last_used_at,omitempty"`
	Token       string                   `json:"token,omitempty"`
	Resources   []OrgAccessTokenResource `json:"resources,omitempty"`
}

type OrgAccessTokenCreateParams added in v0.6.0

type OrgAccessTokenCreateParams struct {
	Label       string                   `json:"label"`
	Description string                   `json:"description"`
	Resources   []OrgAccessTokenResource `json:"resources"`
	ExpiresAt   string                   `json:"expires_at,omitempty"`
}

type OrgAccessTokenResource added in v0.6.0

type OrgAccessTokenResource struct {
	Type   string   `json:"type"`
	Path   string   `json:"path"`
	Scopes []string `json:"scopes"`
}

type OrgAccessTokenUpdateParams added in v0.6.0

type OrgAccessTokenUpdateParams struct {
	Label       string                   `json:"label"`
	Description string                   `json:"description"`
	Resources   []OrgAccessTokenResource `json:"resources"`
}

type OrgInvite

type OrgInvite struct {
	ID              string `json:"id"`
	InviterUsername string `json:"inviter_username"`
	Invitee         string `json:"invitee"`
	Team            string `json:"team"`
	Org             string `json:"org"`
	Role            string `json:"role"`
	CreatedAt       string `json:"created_at"`
}

type OrgInviteResponse

type OrgInviteResponse struct {
	OrgInvitees []OrgInvitee `json:"invitees"`
}

type OrgInvitee

type OrgInvitee struct {
	Invitee string    `json:"invitee"`
	Status  string    `json:"status"`
	Invite  OrgInvite `json:"invite"`
}

type OrgInvitesListResponse added in v0.4.0

type OrgInvitesListResponse struct {
	Data []OrgInvite `json:"data"`
}

type OrgMember added in v0.4.0

type OrgMember struct {
	Email         string   `json:"email"`          // User's email address
	Role          string   `json:"role"`           // Enum: "Owner", "Member", "Invitee" - User's role in the Organization
	Groups        []string `json:"groups"`         // Groups (Teams) that the user is member of
	IsGuest       bool     `json:"is_guest"`       // If the organization has verified domains
	ID            string   `json:"id"`             // The UUID trimmed
	Company       string   `json:"company"`        // Company name
	DateJoined    string   `json:"date_joined"`    // Date joined
	FullName      string   `json:"full_name"`      // Full name
	GravatarEmail string   `json:"gravatar_email"` // Gravatar email
	GravatarURL   string   `json:"gravatar_url"`   // Gravatar URL
	Location      string   `json:"location"`       // Location
	ProfileURL    string   `json:"profile_url"`    // Profile URL
	Type          string   `json:"type"`           // Enum: "User", "Org"
	Username      string   `json:"username"`       // Username
}

OrgMember represents each organization member

type OrgMemberListResponse added in v0.4.0

type OrgMemberListResponse struct {
	Count    int         `json:"count"`    // The total number of items that match with the search.
	Previous string      `json:"previous"` // The URL or link for the previous page of items.
	Next     string      `json:"next"`     // The URL or link for the next page of items.
	Results  []OrgMember `json:"results"`  // List of accounts.
}

OrgMemberList response

type OrgMemberRequest

type OrgMemberRequest struct {
	Org      string   `json:"org"`
	Team     string   `json:"team"`
	Invitees []string `json:"invitees"`
	Role     string   `json:"role"`
	DryRun   bool     `json:"dry_run"`
}

type OrgRoleParam added in v0.5.3

type OrgRoleParam string

Weirdly, org role params are lowercase even though org role return values are uppercase.

const (
	OrgRoleParamOwner  OrgRoleParam = "owner"
	OrgRoleParamEditor OrgRoleParam = "editor"
	OrgRoleParamMember OrgRoleParam = "member"
)

type OrgSettingImageAccessManagement

type OrgSettingImageAccessManagement struct {
	RestrictedImages ImageAccessManagementRestrictedImages `json:"restricted_images"`
}

type OrgSettingRegistryAccessManagement

type OrgSettingRegistryAccessManagement struct {
	Enabled            bool                                       `json:"enabled"`
	StandardRegistries []RegistryAccessManagementStandardRegistry `json:"standard_registries"`
	CustomRegistries   []RegistryAccessManagementCustomRegistry   `json:"custom_registries"`
}

type OrgSettings

type OrgSettings struct {
	OrgName     string `json:"id,omitempty"`
	TeamName    string `json:"team_name,omitempty"`
	Permissions string `json:"restricted_images"`
}

type OrgTeam

type OrgTeam struct {
	ID          int64  `json:"id"`
	UUID        string `json:"uuid"`
	Name        string `json:"name"`
	Description string `json:"description"`
	MemberCount int    `json:"member_count"`
}

type OrgTeamMember

type OrgTeamMember struct {
	ID              string   `json:"id,omitempty"`
	OrgName         string   `json:"org_name,omitempty"`
	TeamName        string   `json:"name"`
	TeamDescription string   `json:"description"`
	UUID            string   `json:"uuid"`
	Username        string   `json:"username"`
	FullName        string   `json:"full_name"`
	Location        string   `json:"location"`
	Company         string   `json:"company"`
	ProfileURL      string   `json:"profile_url"`
	DateJoined      string   `json:"date_joined"`
	GravatarURL     string   `json:"gravatar_url"`
	GravatarEmail   string   `json:"gravatar_email"`
	Type            string   `json:"type"`
	Email           string   `json:"email"`
	Role            string   `json:"role"`
	Groups          []string `json:"groups"`
	IsGuest         bool     `json:"is_guest"`
	PrimaryEmail    string   `json:"primary_email"`
}

type OrgTeamMemberRequest

type OrgTeamMemberRequest struct {
	Member string `json:"member"`
}

type OrgTeamMembersResponse added in v0.4.0

type OrgTeamMembersResponse struct {
	Count    int             `json:"count"`
	Next     string          `json:"next"`
	Previous string          `json:"previous"`
	Results  []OrgTeamMember `json:"results"`
}

type Permissions

type Permissions struct {
	Read  bool `json:"read"`
	Write bool `json:"write"`
	Admin bool `json:"admin"`
}

type RegistryAccessManagementCustomRegistry

type RegistryAccessManagementCustomRegistry struct {
	Address      string `json:"address"`
	FriendlyName string `json:"friendly_name"`
	Allowed      bool   `json:"allowed"`
}

type RegistryAccessManagementStandardRegistry

type RegistryAccessManagementStandardRegistry struct {
	ID      string `json:"id"`
	Allowed bool   `json:"allowed"`
}

type Repositories

type Repositories struct {
	Count    int          `json:"count"`
	Next     interface{}  `json:"next,omitempty"`
	Previous interface{}  `json:"previous,omitempty"`
	Results  []Repository `json:"results"`
}

type Repository

type Repository struct {
	Name                  string                `json:"name"`
	Namespace             string                `json:"namespace"`
	RepositoryType        string                `json:"repository_type,omitempty"`
	IsPrivate             bool                  `json:"is_private"`
	Status                int                   `json:"status"`
	StatusDescription     string                `json:"status_description"`
	Description           string                `json:"description"`
	StarCount             int64                 `json:"star_count"`
	PullCount             int64                 `json:"pull_count"`
	LastUpdated           string                `json:"last_updated"`
	DateRegistered        string                `json:"date_registered"`
	Affiliation           string                `json:"affiliation"`
	MediaTypes            []string              `json:"media_types,omitempty"`
	ContentTypes          []string              `json:"content_types,omitempty"`
	User                  string                `json:"use"`
	IsAutomated           bool                  `json:"is_automated"`
	CollaboratorCount     int64                 `json:"collaborator_count"`
	HubUser               string                `json:"hub_user"`
	HasStarred            bool                  `json:"has_starred"`
	FullDescription       string                `json:"full_description"`
	Permissions           Permissions           `json:"permissions"`
	ImmutableTagsSettings ImmutableTagsSettings `json:"immutable_tags_settings"`
}

type SetRepositoryPrivacyRequest

type SetRepositoryPrivacyRequest struct {
	IsPrivate bool `json:"is_private"`
}

type Tag added in v0.5.0

type Tag struct {
	Name            string     `json:"name"`
	FullSize        int64      `json:"full_size"`
	ID              int64      `json:"id"`
	Repository      int64      `json:"repository"`
	Creator         int64      `json:"creator"`
	LastUpdated     string     `json:"last_updated"`
	LastUpdater     int64      `json:"last_updater"`
	LastUpdaterName string     `json:"last_updater_username"`
	ImageID         string     `json:"image_id"`
	V2              bool       `json:"v2"`
	TagStatus       string     `json:"tag_status"`
	TagLastPulled   string     `json:"tag_last_pulled"`
	TagLastPushed   string     `json:"tag_last_pushed"`
	MediaType       string     `json:"media_type"`
	ContentType     string     `json:"content_type"`
	Digest          string     `json:"digest"`
	Images          []TagImage `json:"images"`
}

type TagImage added in v0.5.0

type TagImage struct {
	Architecture string `json:"architecture"`
	Features     string `json:"features"`
	Variant      string `json:"variant"`
	Digest       string `json:"digest"`
	OS           string `json:"os"`
	OSFeatures   string `json:"os_features"`
	OSVersion    string `json:"os_version"`
	Size         int64  `json:"size"`
	Status       string `json:"status"`
	LastPulled   string `json:"last_pulled"`
	LastPushed   string `json:"last_pushed"`
}

type Tags added in v0.5.0

type Tags struct {
	Count    int         `json:"count"`
	Next     interface{} `json:"next,omitempty"`
	Previous interface{} `json:"previous,omitempty"`
	Results  []Tag       `json:"results"`
}

type TeamRepoPermission

type TeamRepoPermission struct {
	TeamID     int64  `json:"group_id"`
	TeamName   string `json:"group_name"`
	Permission string `json:"permission"`
}

type TeamRepoPermissionLevel

type TeamRepoPermissionLevel string

type TokenProvider added in v0.5.0

type TokenProvider interface {
	// EnsureToken returns a valid token, refreshing if necessary
	EnsureToken(ctx context.Context) (token string, err error)
	// Username returns the username associated with this provider (for display purposes)
	Username() string
}

TokenProvider provides a valid authentication token for API requests

type UpdateRepositoryRequest

type UpdateRepositoryRequest struct {
	Description        string `json:"description"`
	FullDescription    string `json:"full_description"`
	ImmutableTags      bool   `json:"immutable_tags"`
	ImmutableTagsRules string `json:"immutable_tags_rules,omitempty"`
}

Jump to

Keyboard shortcuts

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