api

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authenticator

type Authenticator interface {
	Authenticate(ctx context.Context) (map[string]string, error)
}

type AzureDevOpsClient

type AzureDevOpsClient struct {
	Config      ConnectionConfig
	RateLimiter *RateLimiter
	// contains filtered or unexported fields
}

func NewAzureDevOpsClient

func NewAzureDevOpsClient(config ConnectionConfig) (*AzureDevOpsClient, error)

func (*AzureDevOpsClient) GetProject

func (c *AzureDevOpsClient) GetProject(ctx context.Context, projectName string) (*Project, error)

func (*AzureDevOpsClient) GetProjects

func (c *AzureDevOpsClient) GetProjects(ctx context.Context) ([]Project, error)

func (*AzureDevOpsClient) GetPullRequestClient

func (c *AzureDevOpsClient) GetPullRequestClient() PullRequestClient

func (*AzureDevOpsClient) GetRepositoryClient added in v0.2.1

func (c *AzureDevOpsClient) GetRepositoryClient() RepositoryClient

func (*AzureDevOpsClient) GetWorkItemClient

func (c *AzureDevOpsClient) GetWorkItemClient() WorkItemClient

func (*AzureDevOpsClient) ValidateConnection

func (c *AzureDevOpsClient) ValidateConnection(ctx context.Context) error

type ChangeDetails

type ChangeDetails struct {
	Path         string     `json:"path"`
	ChangeType   ChangeType `json:"changeType"`
	AddedLines   int        `json:"addedLines"`
	RemovedLines int        `json:"removedLines"`
	Content      *struct {
		OriginalContent *string `json:"originalContent,omitempty"`
		NewContent      *string `json:"newContent,omitempty"`
		Diff            *string `json:"diff,omitempty"`
	} `json:"content,omitempty"`
}

type ChangeItem added in v0.2.4

type ChangeItem struct {
	ObjectID string `json:"objectId"`
	Path     string `json:"path"`
}

type ChangeSummary

type ChangeSummary struct {
	TotalAddedLines   int `json:"totalAddedLines"`
	TotalRemovedLines int `json:"totalRemovedLines"`
	FilesAdded        int `json:"filesAdded"`
	FilesEdited       int `json:"filesEdited"`
	FilesDeleted      int `json:"filesDeleted"`
}

type ChangeType

type ChangeType string
const (
	ChangeTypeAdd    ChangeType = "add"
	ChangeTypeEdit   ChangeType = "edit"
	ChangeTypeDelete ChangeType = "delete"
	ChangeTypeRename ChangeType = "rename"
	ChangeTypePerm   ChangeType = "permission"
)

type ClientFactory

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

func GetClientFactory

func GetClientFactory() *ClientFactory

func InitClientFactory

func InitClientFactory() *ClientFactory

func (*ClientFactory) ClearClients

func (f *ClientFactory) ClearClients()

func (*ClientFactory) GetClient

func (f *ClientFactory) GetClient(org, project, token string) (*AzureDevOpsClient, error)

type CommentPosition

type CommentPosition struct {
	Line   int  `json:"line"`
	Offset *int `json:"offset,omitempty"`
}

type CommentType

type CommentType string
const (
	CommentTypeText       CommentType = "text"
	CommentTypeSuggestion CommentType = "suggestion"
)

type ConnectionConfig

type ConnectionConfig struct {
	Organization string
	Project      string
	BaseURL      string
	Token        string
}

func NewConnectionConfig

func NewConnectionConfig(organization, project, token string) ConnectionConfig

type DetailedChange

type DetailedChange struct {
	ChangeID      int          `json:"changeId"`
	ItemID        string       `json:"itemId"`
	Path          string       `json:"path"`
	OriginalPath  *string      `json:"originalPath,omitempty"`
	ChangeType    ChangeType   `json:"changeType"`
	AddedLines    int          `json:"addedLines"`
	RemovedLines  int          `json:"removedLines"`
	IsBinary      bool         `json:"isBinary"`
	IsTruncated   bool         `json:"isTruncated"`
	Diff          *DiffContent `json:"diff,omitempty"`
	SourceVersion *string      `json:"sourceVersion,omitempty"`
	TargetVersion *string      `json:"targetVersion,omitempty"`
}

type DiffContent

type DiffContent struct {
	Content   string `json:"content"`
	Truncated bool   `json:"truncated"`
}

type FileChangeSummary

type FileChangeSummary struct {
	Path         string `json:"path"`
	ChangeType   string `json:"changeType"`
	AddedLines   int    `json:"addedLines"`
	RemovedLines int    `json:"removedLines"`
}

type FileDiff added in v0.2.5

type FileDiff struct {
	Path         string `json:"path"`
	ChangeType   string `json:"changeType"`
	OriginalPath string `json:"originalPath,omitempty"`
	Diff         string `json:"diff,omitempty"`
	Additions    int    `json:"additions"`
	Deletions    int    `json:"deletions"`
	IsBinary     bool   `json:"isBinary"`
	IsTooLarge   bool   `json:"isTooLarge,omitempty"`
}

type GitChange

type GitChange struct {
	ChangeID         int                `json:"changeId"`
	ItemID           string             `json:"itemId"`
	Path             string             `json:"path"`
	OriginalPath     *string            `json:"originalPath,omitempty"`
	ChangeType       ChangeType         `json:"changeType"`
	SourceServerItem *string            `json:"sourceServerItem,omitempty"`
	TargetServerItem *string            `json:"targetServerItem,omitempty"`
	SourceVersion    *string            `json:"sourceVersion,omitempty"`
	TargetVersion    *string            `json:"targetVersion,omitempty"`
	SourceEncoding   *string            `json:"sourceEncoding,omitempty"`
	TargetEncoding   *string            `json:"targetEncoding,omitempty"`
	Links            map[string]LinkRef `json:"_links,omitempty"`
}

type GitCommitRef

type GitCommitRef struct {
	CommitID string       `json:"commitId"`
	URL      string       `json:"url,omitempty"`
	Author   *GitUserDate `json:"author,omitempty"`
	Comment  string       `json:"comment,omitempty"`
}

type GitRef

type GitRef struct {
	CommitID     string `json:"commitId"`
	RepositoryID string `json:"repositoryId,omitempty"`
	URL          string `json:"url,omitempty"`
}

type GitRepository added in v0.2.1

type GitRepository struct {
	ID            string      `json:"id"`
	Name          string      `json:"name"`
	URL           string      `json:"url"`
	RemoteURL     string      `json:"remoteUrl,omitempty"`
	SSHURL        string      `json:"sshUrl,omitempty"`
	WebURL        string      `json:"webUrl,omitempty"`
	DefaultBranch string      `json:"defaultBranch,omitempty"`
	Project       *ProjectRef `json:"project,omitempty"`
	Size          int64       `json:"size,omitempty"`
}

type GitUserDate

type GitUserDate struct {
	Name  string `json:"name"`
	Email string `json:"email"`
	Date  string `json:"date"`
}

type IdentityRef

type IdentityRef struct {
	DisplayName string `json:"displayName"`
	UniqueName  string `json:"uniqueName"`
	ID          string `json:"id"`
	ImageURL    string `json:"imageUrl,omitempty"`
}

type IterationChangeEntry

type IterationChangeEntry struct {
	ChangeID         int         `json:"changeId"`
	Item             *ChangeItem `json:"item,omitempty"`
	ItemID           string      `json:"itemId"`
	Path             string      `json:"path"`
	OriginalPath     *string     `json:"originalPath,omitempty"`
	ChangeType       ChangeType  `json:"changeType"`
	SourceServerItem *string     `json:"sourceServerItem,omitempty"`
	TargetServerItem *string     `json:"targetServerItem,omitempty"`
	SourceVersion    *string     `json:"sourceVersion,omitempty"`
	TargetVersion    *string     `json:"targetVersion,omitempty"`
	SourceEncoding   *string     `json:"sourceEncoding,omitempty"`
	TargetEncoding   *string     `json:"targetEncoding,omitempty"`
	IsBinary         *bool       `json:"isBinary,omitempty"`
	Content          *struct {
		OriginalContent *string `json:"originalContent,omitempty"`
		NewContent      *string `json:"newContent,omitempty"`
	} `json:"content,omitempty"`
	URL   *string            `json:"url,omitempty"`
	Links map[string]LinkRef `json:"_links,omitempty"`
}

type IterationChangesResponse

type IterationChangesResponse struct {
	ChangeEntries          []IterationChangeEntry `json:"changeEntries"`
	CommonAncestorCommit   *string                `json:"commonAncestorCommit,omitempty"`
	CommonAncestorCommitID *string                `json:"commonAncestorCommitId,omitempty"`
	BaseIteration          *IterationRef          `json:"baseIteration,omitempty"`
	TargetIteration        *IterationRef          `json:"targetIteration,omitempty"`
	HasMoreChanges         *bool                  `json:"hasMoreChanges,omitempty"`
}

type IterationRef

type IterationRef struct {
	ID            int     `json:"id"`
	FirstCommitID *string `json:"firstCommitId,omitempty"`
	LastCommitID  *string `json:"lastCommitId,omitempty"`
}

type JsonPatchOperation

type JsonPatchOperation struct {
	Op    string      `json:"op"`
	Path  string      `json:"path"`
	Value interface{} `json:"value,omitempty"`
}

type LinkRef

type LinkRef struct {
	HRef string `json:"href"`
}

type PRSummary

type PRSummary struct {
	PullRequestID int                 `json:"pullRequestId"`
	Title         string              `json:"title"`
	Status        string              `json:"status"`
	SourceBranch  string              `json:"sourceBranch"`
	TargetBranch  string              `json:"targetBranch"`
	TotalChanges  int                 `json:"totalChanges"`
	Files         []FileChangeSummary `json:"files"`
	Summary       ChangeSummary       `json:"summary"`
}

type PersonalAccessTokenAuth

type PersonalAccessTokenAuth struct {
	Token string
}

func NewPersonalAccessTokenAuth

func NewPersonalAccessTokenAuth(token string) *PersonalAccessTokenAuth

func (*PersonalAccessTokenAuth) Authenticate

func (a *PersonalAccessTokenAuth) Authenticate(ctx context.Context) (map[string]string, error)

type Project

type Project struct {
	ID             string `json:"id"`
	Name           string `json:"name"`
	URL            string `json:"url"`
	State          string `json:"state"`
	Revision       int    `json:"revision"`
	Visibility     string `json:"visibility,omitempty"`
	LastUpdateTime string `json:"lastUpdateTime,omitempty"`
}

type ProjectRef

type ProjectRef struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	URL  string `json:"url"`
}

type ProjectsResponse

type ProjectsResponse struct {
	Count int       `json:"count"`
	Value []Project `json:"value"`
}

type PullRequest

type PullRequest struct {
	PullRequestID         int                `json:"pullRequestId"`
	CodeReviewID          *int               `json:"codeReviewId,omitempty"`
	Status                PullRequestStatus  `json:"status"`
	CreatedBy             *IdentityRef       `json:"createdBy,omitempty"`
	CreationDate          *string            `json:"creationDate,omitempty"`
	Title                 string             `json:"title"`
	Description           *string            `json:"description,omitempty"`
	SourceRefName         *string            `json:"sourceRefName,omitempty"`
	TargetRefName         *string            `json:"targetRefName,omitempty"`
	MergeStatus           *string            `json:"mergeStatus,omitempty"`
	IsDraft               *bool              `json:"isDraft,omitempty"`
	MergeID               *string            `json:"mergeId,omitempty"`
	LastMergeSourceCommit *GitCommitRef      `json:"lastMergeSourceCommit,omitempty"`
	LastMergeTargetCommit *GitCommitRef      `json:"lastMergeTargetCommit,omitempty"`
	LastMergeCommit       *GitCommitRef      `json:"lastMergeCommit,omitempty"`
	Reviewers             []Reviewer         `json:"reviewers,omitempty"`
	URL                   *string            `json:"url,omitempty"`
	SupportsIterations    *bool              `json:"supportsIterations,omitempty"`
	Repository            *RepositoryRef     `json:"repository,omitempty"`
	Links                 map[string]LinkRef `json:"_links,omitempty"`
}

type PullRequestClient

type PullRequestClient interface {
	ListPullRequests(ctx context.Context, project, repo string, status PullRequestStatus) ([]PullRequest, error)
	GetPullRequest(ctx context.Context, project, repo string, prID int) (*PullRequest, error)
	GetPullRequestChanges(ctx context.Context, project, repo string, prID int) ([]GitChange, error)
	GetPullRequestIterations(ctx context.Context, project, repo string, prID int) ([]PullRequestIteration, error)
	GetIterationChanges(ctx context.Context, project, repo string, prID, iterationID int) ([]GitChange, error)
	GetThreads(ctx context.Context, project, repo string, prID int) ([]PullRequestThreadSummary, error)
	CreateThread(ctx context.Context, project, repo string, prID int, thread *PullRequestThread) (*PullRequestThread, error)
	PostComment(ctx context.Context, project, repo string, prID, threadID int, comment string) (*PullRequestComment, error)
	GetPullRequestSummary(ctx context.Context, project, repo string, prID int) (*PRSummary, error)
	GetPullRequestDiff(ctx context.Context, project, repo string, prID int, maxFiles int) (*PullRequestDiff, error)
	VoteReviewer(ctx context.Context, project, repo string, prID int, userID string, vote int) error
}

func GetPullRequestClient

func GetPullRequestClient(ctx context.Context, organization, project, token string) (PullRequestClient, error)

func NewPullRequestClient

func NewPullRequestClient(client *AzureDevOpsClient) PullRequestClient

type PullRequestComment

type PullRequestComment struct {
	ID              int          `json:"id"`
	Content         string       `json:"content"`
	CommentType     CommentType  `json:"commentType"`
	Author          *IdentityRef `json:"author,omitempty"`
	CreatedDate     string       `json:"createdDate"`
	ModifiedDate    *string      `json:"modifiedDate,omitempty"`
	IsDeleted       *bool        `json:"isDeleted,omitempty"`
	ParentCommentID *int         `json:"parentCommentId,omitempty"`
}

type PullRequestDiff added in v0.2.5

type PullRequestDiff struct {
	PullRequestID  int        `json:"pullRequestId"`
	Title          string     `json:"title"`
	SourceBranch   string     `json:"sourceBranch"`
	TargetBranch   string     `json:"targetBranch"`
	Files          []FileDiff `json:"files"`
	TotalAdditions int        `json:"totalAdditions"`
	TotalDeletions int        `json:"totalDeletions"`
	TotalFiles     int        `json:"totalFiles"`
}

type PullRequestIteration

type PullRequestIteration struct {
	ID              int          `json:"id"`
	FirstCommitID   *string      `json:"firstCommitId,omitempty"`
	LastCommitID    *string      `json:"lastCommitId,omitempty"`
	Author          *IdentityRef `json:"author,omitempty"`
	CreatedDate     *string      `json:"createdDate,omitempty"`
	Description     *string      `json:"description,omitempty"`
	SourceRefCommit *GitRef      `json:"sourceRefCommit,omitempty"`
	TargetRefCommit *GitRef      `json:"targetRefCommit,omitempty"`
	HasMoreChanges  *bool        `json:"hasMoreChanges,omitempty"`
}

type PullRequestStatus

type PullRequestStatus string
const (
	PullRequestStatusActive    PullRequestStatus = "active"
	PullRequestStatusAbandoned PullRequestStatus = "abandoned"
	PullRequestStatusCompleted PullRequestStatus = "completed"
	PullRequestStatusNotSet    PullRequestStatus = "notSet"
	PullRequestStatusAll       PullRequestStatus = "all"
)

type PullRequestThread

type PullRequestThread struct {
	ID               int                `json:"id,omitempty"`
	Status           *ThreadStatus      `json:"status,omitempty"`
	ThreadContext    *ThreadContext     `json:"threadContext,omitempty"`
	Comments         []ThreadComment    `json:"comments"`
	IsDeleted        *bool              `json:"isDeleted,omitempty"`
	ThreadType       *ThreadType        `json:"threadType,omitempty"`
	Links            map[string]LinkRef `json:"_links,omitempty"`
	SuggestedChanges []SuggestedChange  `json:"suggestedChanges,omitempty"`
}

type PullRequestThreadSummary

type PullRequestThreadSummary struct {
	ID           int    `json:"id"`
	Status       string `json:"status"`
	File         string `json:"file,omitempty"`
	Comment      string `json:"comment"`
	CommentCount int    `json:"commentCount"`
}

type RateLimiter

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

func NewRateLimiter

func NewRateLimiter(maxTokens float64, refillRate float64) *RateLimiter

func (*RateLimiter) Acquire

func (r *RateLimiter) Acquire(tokens float64) bool

func (*RateLimiter) WaitForToken

func (r *RateLimiter) WaitForToken(ctx context.Context, tokens float64) error

type Reaction

type Reaction struct {
	ID    int    `json:"id"`
	Type  string `json:"type"`
	Count int    `json:"count"`
}

type RepositoryClient added in v0.2.1

type RepositoryClient interface {
	ListRepositories(ctx context.Context, project string) ([]GitRepository, error)
	GetRepository(ctx context.Context, project, repoName string) (*GitRepository, error)
}

func GetRepositoryClient added in v0.2.1

func GetRepositoryClient(ctx context.Context, organization, project, token string) (RepositoryClient, error)

func NewRepositoryClient added in v0.2.1

func NewRepositoryClient(client *AzureDevOpsClient) RepositoryClient

type RepositoryRef

type RepositoryRef struct {
	ID      string      `json:"id"`
	Name    string      `json:"name"`
	URL     string      `json:"url"`
	Project *ProjectRef `json:"project,omitempty"`
}

type Reviewer

type Reviewer struct {
	ReviewerURL *string      `json:"reviewerUrl,omitempty"`
	Vote        int          `json:"vote"`
	VotedBy     *IdentityRef `json:"votedBy,omitempty"`
	IsRequired  *bool        `json:"isRequired,omitempty"`
}

type SuggestedChange

type SuggestedChange struct {
	OriginalContent *string `json:"originalContent,omitempty"`
	NewContent      *string `json:"newContent,omitempty"`
	Description     *string `json:"description,omitempty"`
}

type ThreadComment

type ThreadComment struct {
	ID              *int          `json:"id,omitempty"`
	Content         string        `json:"content"`
	CommentType     *CommentType  `json:"commentType,omitempty"`
	Author          *IdentityRef  `json:"author,omitempty"`
	CreatedDate     *string       `json:"createdDate,omitempty"`
	ModifiedDate    *string       `json:"modifiedDate,omitempty"`
	IsDeleted       *bool         `json:"isDeleted,omitempty"`
	ParentCommentID *int          `json:"parentCommentId,omitempty"`
	Reactions       []Reaction    `json:"reactions,omitempty"`
	Likes           []IdentityRef `json:"likes,omitempty"`
}

type ThreadContext

type ThreadContext struct {
	FilePath         *string           `json:"filePath,omitempty"`
	RightFileStart   *CommentPosition  `json:"rightFileStart,omitempty"`
	RightFileEnd     *CommentPosition  `json:"rightFileEnd,omitempty"`
	LeftFileStart    *CommentPosition  `json:"leftFileStart,omitempty"`
	LeftFileEnd      *CommentPosition  `json:"leftFileEnd,omitempty"`
	TrackingCriteria *TrackingCriteria `json:"trackingCriteria,omitempty"`
}

type ThreadStatus

type ThreadStatus string
const (
	ThreadStatusActive  ThreadStatus = "active"
	ThreadStatusFixed   ThreadStatus = "fixed"
	ThreadStatusWontFix ThreadStatus = "wontFix"
	ThreadStatusClosed  ThreadStatus = "closed"
	ThreadStatusPending ThreadStatus = "pending"
)

type ThreadType

type ThreadType string
const (
	ThreadTypeBug      ThreadType = "bug"
	ThreadTypeIssue    ThreadType = "issue"
	ThreadTypeQuestion ThreadType = "question"
	ThreadTypeGeneral  ThreadType = "general"
)

type TrackingCriteria

type TrackingCriteria struct {
	FirstLine *int `json:"firstLine,omitempty"`
	LastLine  *int `json:"lastLine,omitempty"`
}

type WiqlColumnRef

type WiqlColumnRef struct {
	Name string `json:"name"`
	URL  string `json:"url"`
}

type WiqlQueryResult

type WiqlQueryResult struct {
	QueryResultType string            `json:"queryResultType"`
	WorkItems       []WiqlWorkItemRef `json:"workItems"`
	Columns         []WiqlColumnRef   `json:"columns"`
}

type WiqlWorkItemRef

type WiqlWorkItemRef struct {
	ID  int    `json:"id"`
	URL string `json:"url"`
}

type WorkItem

type WorkItem struct {
	ID        int                `json:"id"`
	Rev       int                `json:"rev"`
	Fields    WorkItemFields     `json:"fields"`
	Relations []WorkItemRelation `json:"relations,omitempty"`
	Links     map[string]LinkRef `json:"_links,omitempty"`
	URL       string             `json:"url"`
}

type WorkItemClient

type WorkItemClient interface {
	GetWorkItem(ctx context.Context, project string, id int, expand *bool) (*WorkItem, error)
	ListWorkItems(ctx context.Context, project string, filters WorkItemFilters) ([]WorkItem, error)
	CreateWorkItem(ctx context.Context, project string, workItemType string, fields map[string]interface{}) (*WorkItem, error)
	UpdateWorkItem(ctx context.Context, project string, id int, updates []map[string]interface{}) (*WorkItem, error)
	GetComments(ctx context.Context, project string, workItemID int) ([]WorkItemComment, error)
	AddComment(ctx context.Context, project string, workItemID int, text string) (*WorkItemComment, error)
	QueryByWiql(ctx context.Context, project string, wiqlQuery string, limit int) ([]WorkItem, error)
	GetWorkItemsBatch(ctx context.Context, project string, ids []int) ([]WorkItem, error)
	GetValidStates(ctx context.Context, project string, workItemID int) ([]string, error)
}

func GetWorkItemClient

func GetWorkItemClient(ctx context.Context, organization, project, token string) (WorkItemClient, error)

func NewWorkItemClient

func NewWorkItemClient(client *AzureDevOpsClient) WorkItemClient

type WorkItemComment

type WorkItemComment struct {
	WorkItemID   int          `json:"workItemId,omitempty"`
	CommentId    int          `json:"commentId,omitempty"`
	Text         string       `json:"text"`
	CreatedDate  string       `json:"createdDate,omitempty"`
	CreatedBy    *IdentityRef `json:"createdBy,omitempty"`
	ModifiedDate string       `json:"modifiedDate,omitempty"`
	ModifiedBy   *IdentityRef `json:"modifiedBy,omitempty"`
	Version      int          `json:"version,omitempty"`
	IsDeleted    bool         `json:"isDeleted,omitempty"`
	URL          string       `json:"url,omitempty"`
}

type WorkItemCommentsResponse

type WorkItemCommentsResponse struct {
	Count             int               `json:"count"`
	Comments          []WorkItemComment `json:"comments"`
	TotalCount        int               `json:"totalCount"`
	ContinuationToken string            `json:"continuationToken,omitempty"`
	NextPage          string            `json:"nextPage,omitempty"`
}

type WorkItemFields

type WorkItemFields map[string]interface{}

type WorkItemFilters

type WorkItemFilters struct {
	State    string
	Assignee string
	Mine     bool
	Type     string
	Limit    int
}

type WorkItemRelation

type WorkItemRelation struct {
	Rel        string                 `json:"rel"`
	URL        string                 `json:"url"`
	Attributes map[string]interface{} `json:"attributes,omitempty"`
}

type WorkItemStateTransition

type WorkItemStateTransition struct {
	ID     int    `json:"id"`
	Name   string `json:"name"`
	From   string `json:"from"`
	To     string `json:"to"`
	Reason string `json:"reason,omitempty"`
}

type WorkItemTypeInfo

type WorkItemTypeInfo struct {
	Name        string                    `json:"name"`
	States      []string                  `json:"states"`
	Transitions []WorkItemStateTransition `json:"transitions,omitempty"`
}

Jump to

Keyboard shortcuts

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