azureapi

package
v0.0.30 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_HOST string = "azure.com"
	DEV_HOST     string = "dev.azure.com"
	SSH_DEV_HOST string = "ssh.dev.azure.com"
)

Variables

This section is empty.

Functions

Types

type AzureAPI

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

func NewAzureAPI

func NewAzureAPI() *AzureAPI

func (*AzureAPI) GetDefaultBranchName

func (az *AzureAPI) GetDefaultBranchName(owner, project, repo string, headers *Headers) (string, error)

func (*AzureAPI) GetFileLatestCommit

func (az *AzureAPI) GetFileLatestCommit(owner, project, repo, branch, fullPath string, headers *Headers) ([]Commit, error)

Get latest commit data of path/file

func (*AzureAPI) GetLatestCommit

func (az *AzureAPI) GetLatestCommit(owner, project, repo, branch string, headers *Headers) (*Commit, error)

func (*AzureAPI) GetRepoTree

func (az *AzureAPI) GetRepoTree(owner, project, repo, branch string, headers *Headers) (*Tree, error)

type BranchValue

type BranchValue struct {
	Commit        CommitsMetadata `json:"commit"`
	Name          string          `json:"name"`
	AheadCount    int             `json:"aheadCount"`
	BehindCount   int             `json:"behindCount"`
	IsBaseVersion bool            `json:"isBaseVersion"`
}

type Commit

type Commit struct {
	Count        int            `json:"count"`
	CommitsValue []CommitsValue `json:"value"`
}

LatestCommit returned structure

type CommitsMetadata

type CommitsMetadata struct {
	TreeID   string `json:"treeId"`
	CommitID string `json:"commitId"`
	Author   struct {
		Name  string    `json:"name"`
		Email string    `json:"email"`
		Date  time.Time `json:"date"`
	} `json:"author"`
	Committer struct {
		Name  string    `json:"name"`
		Email string    `json:"email"`
		Date  time.Time `json:"date"`
	} `json:"committer"`
	Comment string   `json:"comment"`
	Parents []string `json:"parents"`
	URL     string   `json:"url"`
}

type CommitsValue

type CommitsValue struct {
	CommitID string `json:"commitId"`
	Author   struct {
		Name  string    `json:"name"`
		Email string    `json:"email"`
		Date  time.Time `json:"date"`
	} `json:"author"`
	Committer struct {
		Name  string    `json:"name"`
		Email string    `json:"email"`
		Date  time.Time `json:"date"`
	} `json:"committer"`
	Comment      string `json:"comment"`
	ChangeCounts struct {
		Add    int `json:"add"`
		Edit   int `json:"edit"`
		Delete int `json:"delete"`
	} `json:"changeCounts"`
	Changes []struct {
		SourceServerItem string `json:"sourceServerItem"`
		ChangeType       string `json:"changeType"`
	} `json:"changes"`
	URL       string `json:"url"`
	RemoteURL string `json:"remoteUrl"`
}

type Headers

type Headers struct {
	Token string
}

func (*Headers) ToMap

func (h *Headers) ToMap() map[string]string

ToMap convert headers to map[string]string

type IAzureAPI

type IAzureAPI interface {
	GetRepoTree(owner, project, repo, branch string, headers *Headers) (*Tree, error)
	GetDefaultBranchName(owner, project, repo string, headers *Headers) (string, error)
	GetLatestCommit(owner, project, repo, branch string, headers *Headers) (*Commit, error)
}

type InnerTree

type InnerTree struct {
	ObjectID      string     `json:"objectId"`
	GitObjectType ObjectType `json:"gitObjectType"`
	CommitID      string     `json:"commitId"`
	Path          string     `json:"path"`
	IsFolder      bool       `json:"isFolder"`
	Url           string     `json:"url"`
}

type MockAzureAPI

type MockAzureAPI struct {
}

func NewMockAzureAPI

func NewMockAzureAPI() *MockAzureAPI

func (MockAzureAPI) GetDefaultBranchName

func (az MockAzureAPI) GetDefaultBranchName(owner, project, repo string, headers *Headers) (string, error)

func (MockAzureAPI) GetLatestCommit

func (az MockAzureAPI) GetLatestCommit(owner, project, repo, branch string, headers *Headers) (*Commit, error)

func (*MockAzureAPI) GetRepoTree

func (az *MockAzureAPI) GetRepoTree(owner, project, repo, branch string, headers *Headers) (*Tree, error)

type ObjectType

type ObjectType string
const (
	ObjectTypeDir  ObjectType = "tree"
	ObjectTypeFile ObjectType = "blob"
)

type Tree

type Tree struct {
	Count     int         `json:"count"`
	InnerTree []InnerTree `json:"value"`
}

func (*Tree) ListAll

func (t *Tree) ListAll() []string

ListAll list all file/dir in repo tree

func (*Tree) ListAllDirs

func (t *Tree) ListAllDirs() []string

ListAllDirs list all directories in repo tree

func (*Tree) ListAllFiles

func (t *Tree) ListAllFiles() []string

ListAllFiles list all files in repo tree

Jump to

Keyboard shortcuts

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