mirror of
https://github.com/gfleury/go-bitbucket-v1.git
synced 2025-04-03 16:30:14 -05:00
Principal call fixes and adding vendor
This commit is contained in:
parent
fa8ce9c2a0
commit
f6de69b5d7
188
api_response.go
188
api_response.go
@ -7,6 +7,9 @@ package bitbucketv1
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/mitchellh/mapstructure"
|
||||
)
|
||||
|
||||
// APIResponse contains generic data from API Response
|
||||
@ -28,6 +31,191 @@ type APIResponse struct {
|
||||
Values map[string]interface{}
|
||||
}
|
||||
|
||||
type Project struct {
|
||||
Key string `json:"key"`
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Public bool `json:"public"`
|
||||
Type string `json:"type"`
|
||||
Links struct {
|
||||
Self []struct {
|
||||
Href string `json:"href"`
|
||||
} `json:"self"`
|
||||
} `json:"links"`
|
||||
}
|
||||
|
||||
// Repository contains data from a BitBucket Repository
|
||||
type Repository struct {
|
||||
Slug string `json:"slug"`
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
ScmID string `json:"scmId"`
|
||||
State string `json:"state"`
|
||||
StatusMessage string `json:"statusMessage"`
|
||||
Forkable bool `json:"forkable"`
|
||||
Project Project `json:"project"`
|
||||
Public bool `json:"public"`
|
||||
Links struct {
|
||||
Clone []struct {
|
||||
Href string `json:"href"`
|
||||
Name string `json:"name"`
|
||||
} `json:"clone"`
|
||||
Self []struct {
|
||||
Href string `json:"href"`
|
||||
} `json:"self"`
|
||||
} `json:"links"`
|
||||
}
|
||||
|
||||
// SSHKey contains data from a SSHKey in the BitBucket Server
|
||||
type SSHKey struct {
|
||||
ID int `json:"id"`
|
||||
Text string `json:"text"`
|
||||
Label string `json:"label"`
|
||||
}
|
||||
|
||||
// Commit contains data from a commit in BitBucket
|
||||
type Commit struct {
|
||||
ID string `json:"id"`
|
||||
DisplayID string `json:"displayId"`
|
||||
Author struct {
|
||||
Name string `json:"name"`
|
||||
EmailAddress string `json:"emailAddress"`
|
||||
} `json:"author"`
|
||||
AuthorTimestamp int64 `json:"authorTimestamp"`
|
||||
Committer struct {
|
||||
Name string `json:"name"`
|
||||
EmailAddress string `json:"emailAddress"`
|
||||
} `json:"committer"`
|
||||
CommitterTimestamp int64 `json:"committerTimestamp"`
|
||||
Message string `json:"message"`
|
||||
Parents []struct {
|
||||
ID string `json:"id"`
|
||||
DisplayID string `json:"displayId"`
|
||||
} `json:"parents"`
|
||||
}
|
||||
|
||||
type Diff struct {
|
||||
Diffs []struct {
|
||||
Source struct {
|
||||
Components []string `json:"components"`
|
||||
Parent string `json:"parent"`
|
||||
Name string `json:"name"`
|
||||
Extension string `json:"extension"`
|
||||
ToString string `json:"toString"`
|
||||
} `json:"source"`
|
||||
Destination struct {
|
||||
Components []string `json:"components"`
|
||||
Parent string `json:"parent"`
|
||||
Name string `json:"name"`
|
||||
Extension string `json:"extension"`
|
||||
ToString string `json:"toString"`
|
||||
} `json:"destination"`
|
||||
Hunks []struct {
|
||||
SourceLine int `json:"sourceLine"`
|
||||
SourceSpan int `json:"sourceSpan"`
|
||||
DestinationLine int `json:"destinationLine"`
|
||||
DestinationSpan int `json:"destinationSpan"`
|
||||
Segments []struct {
|
||||
Type string `json:"type"`
|
||||
Lines []struct {
|
||||
Destination int `json:"destination"`
|
||||
Source int `json:"source"`
|
||||
Line string `json:"line"`
|
||||
Truncated bool `json:"truncated"`
|
||||
} `json:"lines"`
|
||||
Truncated bool `json:"truncated"`
|
||||
} `json:"segments"`
|
||||
Truncated bool `json:"truncated"`
|
||||
} `json:"hunks"`
|
||||
Truncated bool `json:"truncated"`
|
||||
ContextLines float64 `json:"contextLines"`
|
||||
FromHash string `json:"fromHash"`
|
||||
ToHash string `json:"toHash"`
|
||||
WhiteSpace string `json:"whiteSpace"`
|
||||
} `json:"diffs"`
|
||||
Truncated bool `json:"truncated"`
|
||||
ContextLines float64 `json:"contextLines"`
|
||||
FromHash string `json:"fromHash"`
|
||||
ToHash string `json:"toHash"`
|
||||
WhiteSpace string `json:"whiteSpace"`
|
||||
}
|
||||
|
||||
// Tag contaings git Tag information
|
||||
type Tag struct {
|
||||
ID string `json:"id"`
|
||||
DisplayID string `json:"displayId"`
|
||||
Type string `json:"type"`
|
||||
LatestCommit string `json:"latestCommit"`
|
||||
LatestChangeset string `json:"latestChangeset"`
|
||||
Hash string `json:"hash"`
|
||||
}
|
||||
|
||||
// Branch contains git Branch information
|
||||
type Branch struct {
|
||||
ID string `json:"id"`
|
||||
DisplayID string `json:"displayId"`
|
||||
Type string `json:"type"`
|
||||
LatestCommit string `json:"latestCommit"`
|
||||
LatestChangeset string `json:"latestChangeset"`
|
||||
IsDefault bool `json:"isDefault"`
|
||||
}
|
||||
|
||||
func (k *SSHKey) String() string {
|
||||
parts := make([]string, 1, 2)
|
||||
parts[0] = strings.TrimSpace(k.Text)
|
||||
return strings.Join(parts, " ")
|
||||
}
|
||||
|
||||
// GetCommitsResponse cast Commits into structure
|
||||
func GetCommitsResponse(r *APIResponse) ([]Commit, error) {
|
||||
var m []Commit
|
||||
err := mapstructure.Decode(r.Values["values"], &m)
|
||||
return m, err
|
||||
}
|
||||
|
||||
// GetTagsResponse cast Tags into structure
|
||||
func GetTagsResponse(r *APIResponse) ([]Tag, error) {
|
||||
var m []Tag
|
||||
err := mapstructure.Decode(r.Values["values"], &m)
|
||||
return m, err
|
||||
}
|
||||
|
||||
// GetBranchesResponse cast Tags into structure
|
||||
func GetBranchesResponse(r *APIResponse) ([]Branch, error) {
|
||||
var m []Branch
|
||||
err := mapstructure.Decode(r.Values["values"], &m)
|
||||
return m, err
|
||||
}
|
||||
|
||||
// GetRepositoriesResponse cast Repositories into structure
|
||||
func GetRepositoriesResponse(r *APIResponse) ([]Repository, error) {
|
||||
var m []Repository
|
||||
err := mapstructure.Decode(r.Values["values"], &m)
|
||||
return m, err
|
||||
}
|
||||
|
||||
// GetRepositoryResponse cast Repositories into structure
|
||||
func GetRepositoryResponse(r *APIResponse) (Repository, error) {
|
||||
var m Repository
|
||||
err := mapstructure.Decode(r.Values, &m)
|
||||
return m, err
|
||||
}
|
||||
|
||||
// GetDiffResponse cast Diff into structure
|
||||
func GetDiffResponse(r *APIResponse) (Diff, error) {
|
||||
var m Diff
|
||||
err := mapstructure.Decode(r.Values, &m)
|
||||
return m, err
|
||||
}
|
||||
|
||||
// GetSSHKeysResponse cast SSHKeys into structure
|
||||
func GetSSHKeysResponse(r *APIResponse) ([]SSHKey, error) {
|
||||
var m []SSHKey
|
||||
err := mapstructure.Decode(r.Values["values"], &m)
|
||||
return m, err
|
||||
}
|
||||
|
||||
// NewAPIResponse create new APIResponse from http.Response
|
||||
func NewAPIResponse(r *http.Response) *APIResponse {
|
||||
|
||||
|
13
cmd/main.go
13
cmd/main.go
@ -16,12 +16,19 @@ func main() {
|
||||
|
||||
client := bitbucketv1.NewAPIClient(
|
||||
ctx,
|
||||
bitbucketv1.NewConfiguration("http://amazonaws.com/rest"),
|
||||
bitbucketv1.NewConfiguration("https://stash.domain.com/rest"),
|
||||
)
|
||||
response, err := client.DefaultApi.GetUsers(nil)
|
||||
username := "george.fleury"
|
||||
response, err := client.DefaultApi.GetSSHKeys(username)
|
||||
if err != nil {
|
||||
fmt.Printf("%s\n", err.Error())
|
||||
}
|
||||
fmt.Printf("%v", response)
|
||||
|
||||
repos, err := bitbucketv1.GetRepositoriesResponse(response)
|
||||
|
||||
if err == nil {
|
||||
for _, repo := range repos {
|
||||
fmt.Println(repo.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
168
default_api.go
168
default_api.go
@ -6,10 +6,11 @@ package bitbucketv1
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"golang.org/x/net/context"
|
||||
"io/ioutil"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// Linger please
|
||||
@ -2903,7 +2904,7 @@ Streams an archive of the repository's contents at the requested commit. If
|
||||
@param "path" (string) paths to include in the streamed archive; may be repeated to include multiple paths
|
||||
@param "prefix" (string) a prefix to apply to all entries in the streamed archive; if the supplied prefix does not end with a trailing <code>/</code>, one will be added automatically
|
||||
@return */
|
||||
func (a *DefaultApiService) GetArchive(localVarOptionals map[string]interface{}) (*APIResponse, error) {
|
||||
func (a *DefaultApiService) GetArchive(project, repository string, localVarOptionals map[string]interface{}) (*APIResponse, error) {
|
||||
var (
|
||||
localVarHTTPMethod = strings.ToUpper("Get")
|
||||
localVarPostBody interface{}
|
||||
@ -2913,6 +2914,8 @@ func (a *DefaultApiService) GetArchive(localVarOptionals map[string]interface{})
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/api/1.0/projects/{projectKey}/repos/{repositorySlug}/archive"
|
||||
localVarPath = strings.Replace(localVarPath, "{"+"projectKey"+"}", fmt.Sprintf("%v", project), -1)
|
||||
localVarPath = strings.Replace(localVarPath, "{"+"repositorySlug"+"}", fmt.Sprintf("%v", repository), -1)
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
@ -3058,7 +3061,7 @@ Retrieve the branches matching the supplied <strong>filterText</strong&
|
||||
@param "filterText" (string) the text to match on
|
||||
@param "orderBy" (string) ordering of refs either ALPHABETICAL (by name) or MODIFICATION (last updated)
|
||||
@return */
|
||||
func (a *DefaultApiService) GetBranches(localVarOptionals map[string]interface{}) (*APIResponse, error) {
|
||||
func (a *DefaultApiService) GetBranches(project, repository string, localVarOptionals map[string]interface{}) (*APIResponse, error) {
|
||||
var (
|
||||
localVarHTTPMethod = strings.ToUpper("Get")
|
||||
localVarPostBody interface{}
|
||||
@ -3068,6 +3071,8 @@ func (a *DefaultApiService) GetBranches(localVarOptionals map[string]interface{}
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/api/1.0/projects/{projectKey}/repos/{repositorySlug}/branches"
|
||||
localVarPath = strings.Replace(localVarPath, "{"+"projectKey"+"}", fmt.Sprintf("%v", project), -1)
|
||||
localVarPath = strings.Replace(localVarPath, "{"+"repositorySlug"+"}", fmt.Sprintf("%v", repository), -1)
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
@ -3631,7 +3636,7 @@ Retrieve a page of commits from a given starting commit or \"between\"
|
||||
@param "until" (string) the commit ID (SHA1) or ref (inclusively) to retrieve commits before
|
||||
@param "withCounts" (bool) optionally include the total number of commits and total number of unique authors
|
||||
@return */
|
||||
func (a *DefaultApiService) GetCommits(localVarOptionals map[string]interface{}) (*APIResponse, error) {
|
||||
func (a *DefaultApiService) GetCommits(project, repository string, localVarOptionals map[string]interface{}) (*APIResponse, error) {
|
||||
var (
|
||||
localVarHTTPMethod = strings.ToUpper("Get")
|
||||
localVarPostBody interface{}
|
||||
@ -3640,7 +3645,7 @@ func (a *DefaultApiService) GetCommits(localVarOptionals map[string]interface{})
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits"
|
||||
localVarPath := fmt.Sprintf("%s/api/1.0/projects/%s/repos/%s/commits", a.client.cfg.BasePath, project, repository)
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
@ -3689,6 +3694,9 @@ func (a *DefaultApiService) GetCommits(localVarOptionals map[string]interface{})
|
||||
if localVarTempParam, localVarOk := localVarOptionals["withCounts"].(bool); localVarOk {
|
||||
localVarQueryParams.Add("withCounts", parameterToString(localVarTempParam, ""))
|
||||
}
|
||||
if localVarTempParam, localVarOk := localVarOptionals["limit"].(int); localVarOk {
|
||||
localVarQueryParams.Add("limit", parameterToString(localVarTempParam, ""))
|
||||
}
|
||||
// to determine the Content-Type header
|
||||
localVarHTTPContentTypes := []string{}
|
||||
|
||||
@ -6040,7 +6048,7 @@ Retrieve the repository matching the supplied <strong>projectKey</stron
|
||||
@param projectKey2 the parent project key
|
||||
@param repositorySlug the repository slug
|
||||
@return */
|
||||
func (a *DefaultApiService) GetRepository(projectKey string, projectKey2 string, repositorySlug string) (*APIResponse, error) {
|
||||
func (a *DefaultApiService) GetRepository(projectKey string, repositorySlug string) (*APIResponse, error) {
|
||||
var (
|
||||
localVarHTTPMethod = strings.ToUpper("Get")
|
||||
localVarPostBody interface{}
|
||||
@ -6051,7 +6059,6 @@ func (a *DefaultApiService) GetRepository(projectKey string, projectKey2 string,
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/api/1.0/projects/{projectKey}/repos/{repositorySlug}"
|
||||
localVarPath = strings.Replace(localVarPath, "{"+"projectKey"+"}", fmt.Sprintf("%v", projectKey), -1)
|
||||
localVarPath = strings.Replace(localVarPath, "{"+"projectKey"+"}", fmt.Sprintf("%v", projectKey2), -1)
|
||||
localVarPath = strings.Replace(localVarPath, "{"+"repositorySlug"+"}", fmt.Sprintf("%v", repositorySlug), -1)
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
@ -6735,7 +6742,7 @@ Retrieve the tags matching the supplied <strong>filterText</strong>
|
||||
@param "filterText" (string) the text to match on
|
||||
@param "orderBy" (string) ordering of refs either ALPHABETICAL (by name) or MODIFICATION (last updated)
|
||||
@return */
|
||||
func (a *DefaultApiService) GetTags(localVarOptionals map[string]interface{}) (*APIResponse, error) {
|
||||
func (a *DefaultApiService) GetTags(project, repository string, localVarOptionals map[string]interface{}) (*APIResponse, error) {
|
||||
var (
|
||||
localVarHTTPMethod = strings.ToUpper("Get")
|
||||
localVarPostBody interface{}
|
||||
@ -6745,6 +6752,8 @@ func (a *DefaultApiService) GetTags(localVarOptionals map[string]interface{}) (*
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/api/1.0/projects/{projectKey}/repos/{repositorySlug}/tags"
|
||||
localVarPath = strings.Replace(localVarPath, "{"+"projectKey"+"}", fmt.Sprintf("%v", project), -1)
|
||||
localVarPath = strings.Replace(localVarPath, "{"+"repositorySlug"+"}", fmt.Sprintf("%v", repository), -1)
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
@ -6854,11 +6863,8 @@ func (a *DefaultApiService) GetTask(taskId int64) (*APIResponse, error) {
|
||||
return NewBitbucketAPIResponse(localVarHTTPResponse)
|
||||
}
|
||||
|
||||
/* DefaultApiService
|
||||
Retrieve the user matching the supplied <strong>userSlug</strong>. <p>
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@return */
|
||||
func (a *DefaultApiService) GetUser(ctx context.Context) (*APIResponse, error) {
|
||||
/*GetSSHKeys retrieve ssh keys per user, param */
|
||||
func (a *DefaultApiService) GetSSHKeys(user string) (*APIResponse, error) {
|
||||
var (
|
||||
localVarHTTPMethod = strings.ToUpper("Get")
|
||||
localVarPostBody interface{}
|
||||
@ -6867,7 +6873,132 @@ func (a *DefaultApiService) GetUser(ctx context.Context) (*APIResponse, error) {
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/api/1.0/users/{userSlug}"
|
||||
localVarPath := a.client.cfg.BasePath + "/ssh/1.0/keys"
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
|
||||
if len(user) != 0 {
|
||||
localVarQueryParams.Add("user", user)
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHTTPContentTypes := []string{}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
||||
if localVarHTTPContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHTTPHeaderAccepts := []string{}
|
||||
|
||||
// set Accept header
|
||||
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
||||
if localVarHTTPHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
||||
}
|
||||
r, err := a.client.prepareRequest(a.client.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
localVarHTTPResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHTTPResponse == nil {
|
||||
return NewBitbucketAPIResponse(localVarHTTPResponse)
|
||||
}
|
||||
defer localVarHTTPResponse.Body.Close()
|
||||
if localVarHTTPResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHTTPResponse.Body)
|
||||
return NewAPIResponseWithError(localVarHTTPResponse, reportError("Status: %v, Body: %s", localVarHTTPResponse.Status, bodyBytes))
|
||||
}
|
||||
|
||||
return NewBitbucketAPIResponse(localVarHTTPResponse)
|
||||
}
|
||||
|
||||
/*CreateSSHKey create ssh key for user, params user and text */
|
||||
func (a *DefaultApiService) CreateSSHKey(localVarOptionals map[string]interface{}) (*APIResponse, error) {
|
||||
var (
|
||||
localVarHTTPMethod = strings.ToUpper("Post")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/ssh/1.0/keys"
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
|
||||
if err := typeCheckParameter(localVarOptionals["user"], "string", "user"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := typeCheckParameter(localVarOptionals["text"], "string", "text"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if localVarTempParam, localVarOk := localVarOptionals["user"].(string); localVarOk {
|
||||
localVarQueryParams.Add("user", parameterToString(localVarTempParam, ""))
|
||||
}
|
||||
if localVarTempParam, localVarOk := localVarOptionals["text"].(string); localVarOk {
|
||||
localVarFormParams.Add("text", parameterToString(localVarTempParam, ""))
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHTTPContentTypes := []string{"application/json"}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
||||
if localVarHTTPContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHTTPHeaderAccepts := []string{}
|
||||
|
||||
// set Accept header
|
||||
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
||||
if localVarHTTPHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
||||
}
|
||||
r, err := a.client.prepareRequest(a.client.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
localVarHTTPResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHTTPResponse == nil {
|
||||
return NewBitbucketAPIResponse(localVarHTTPResponse)
|
||||
}
|
||||
defer localVarHTTPResponse.Body.Close()
|
||||
if localVarHTTPResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHTTPResponse.Body)
|
||||
return NewAPIResponseWithError(localVarHTTPResponse, reportError("Status: %v, Body: %s", localVarHTTPResponse.Status, bodyBytes))
|
||||
}
|
||||
|
||||
return NewBitbucketAPIResponse(localVarHTTPResponse)
|
||||
}
|
||||
|
||||
/* DefaultApiService
|
||||
Retrieve the user matching the supplied <strong>userSlug</strong>. <p>
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@return */
|
||||
func (a *DefaultApiService) GetUser(username string) (*APIResponse, error) {
|
||||
var (
|
||||
localVarHTTPMethod = strings.ToUpper("Get")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/api/1.0/users/"
|
||||
|
||||
localVarPath = fmt.Sprint("%s%s", localVarPath, username)
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
@ -9731,7 +9862,7 @@ Gets the commits accessible from the {@code from} commit but not in the {@code t
|
||||
@param "to" (string) the target commit (can be a partial/full commit ID or qualified/unqualified ref name)
|
||||
@param "fromRepo" (string) an optional parameter specifying the source repository containing the source commit if that commit is not present in the current repository; the repository can be specified by either its ID <em>fromRepo=42</em> or by its project key plus its repo slug separated by a slash: <em>fromRepo=projectKey/repoSlug</em>
|
||||
@return */
|
||||
func (a *DefaultApiService) StreamCommits(localVarOptionals map[string]interface{}) (*APIResponse, error) {
|
||||
func (a *DefaultApiService) StreamCommits(project, repository string, localVarOptionals map[string]interface{}) (*APIResponse, error) {
|
||||
var (
|
||||
localVarHTTPMethod = strings.ToUpper("Get")
|
||||
localVarPostBody interface{}
|
||||
@ -9740,7 +9871,7 @@ func (a *DefaultApiService) StreamCommits(localVarOptionals map[string]interface
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/api/1.0/projects/{projectKey}/repos/{repositorySlug}/compare/commits"
|
||||
localVarPath := fmt.Sprintf("%s/api/1.0/projects/%s/repos/%s/compare/commits", a.client.cfg.BasePath, project, repository)
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
@ -10016,7 +10147,7 @@ Gets a diff of the changes available in the {@code from} commit but not in the {
|
||||
@param "contextLines" (int32) an optional number of context lines to include around each added or removed lines in the diff
|
||||
@param "whitespace" (string) an optional whitespace flag which can be set to <code>ignore-all</code>
|
||||
@return */
|
||||
func (a *DefaultApiService) StreamDiff_37(path string, localVarOptionals map[string]interface{}) (*APIResponse, error) {
|
||||
func (a *DefaultApiService) StreamDiff_37(project, repository, path string, localVarOptionals map[string]interface{}) (*APIResponse, error) {
|
||||
var (
|
||||
localVarHTTPMethod = strings.ToUpper("Get")
|
||||
localVarPostBody interface{}
|
||||
@ -10025,8 +10156,7 @@ func (a *DefaultApiService) StreamDiff_37(path string, localVarOptionals map[str
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/api/1.0/projects/{projectKey}/repos/{repositorySlug}/compare/diff{path}"
|
||||
localVarPath = strings.Replace(localVarPath, "{"+"path"+"}", fmt.Sprintf("%v", path), -1)
|
||||
localVarPath := fmt.Sprintf("%s/api/1.0/projects/%s/repos/%s/compare/diff%s", a.client.cfg.BasePath, project, repository, path)
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
|
21
vendor/github.com/mitchellh/mapstructure/LICENSE
generated
vendored
Normal file
21
vendor/github.com/mitchellh/mapstructure/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 Mitchell Hashimoto
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
46
vendor/github.com/mitchellh/mapstructure/README.md
generated
vendored
Normal file
46
vendor/github.com/mitchellh/mapstructure/README.md
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
# mapstructure [](https://godoc.org/github.com/mitchellh/mapstructure)
|
||||
|
||||
mapstructure is a Go library for decoding generic map values to structures
|
||||
and vice versa, while providing helpful error handling.
|
||||
|
||||
This library is most useful when decoding values from some data stream (JSON,
|
||||
Gob, etc.) where you don't _quite_ know the structure of the underlying data
|
||||
until you read a part of it. You can therefore read a `map[string]interface{}`
|
||||
and use this library to decode it into the proper underlying native Go
|
||||
structure.
|
||||
|
||||
## Installation
|
||||
|
||||
Standard `go get`:
|
||||
|
||||
```
|
||||
$ go get github.com/mitchellh/mapstructure
|
||||
```
|
||||
|
||||
## Usage & Example
|
||||
|
||||
For usage and examples see the [Godoc](http://godoc.org/github.com/mitchellh/mapstructure).
|
||||
|
||||
The `Decode` function has examples associated with it there.
|
||||
|
||||
## But Why?!
|
||||
|
||||
Go offers fantastic standard libraries for decoding formats such as JSON.
|
||||
The standard method is to have a struct pre-created, and populate that struct
|
||||
from the bytes of the encoded format. This is great, but the problem is if
|
||||
you have configuration or an encoding that changes slightly depending on
|
||||
specific fields. For example, consider this JSON:
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "person",
|
||||
"name": "Mitchell"
|
||||
}
|
||||
```
|
||||
|
||||
Perhaps we can't populate a specific structure without first reading
|
||||
the "type" field from the JSON. We could always do two passes over the
|
||||
decoding of the JSON (reading the "type" first, and the rest later).
|
||||
However, it is much simpler to just decode this into a `map[string]interface{}`
|
||||
structure, read the "type" key, then use something like this library
|
||||
to decode it into the proper structure.
|
171
vendor/github.com/mitchellh/mapstructure/decode_hooks.go
generated
vendored
Normal file
171
vendor/github.com/mitchellh/mapstructure/decode_hooks.go
generated
vendored
Normal file
@ -0,0 +1,171 @@
|
||||
package mapstructure
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// typedDecodeHook takes a raw DecodeHookFunc (an interface{}) and turns
|
||||
// it into the proper DecodeHookFunc type, such as DecodeHookFuncType.
|
||||
func typedDecodeHook(h DecodeHookFunc) DecodeHookFunc {
|
||||
// Create variables here so we can reference them with the reflect pkg
|
||||
var f1 DecodeHookFuncType
|
||||
var f2 DecodeHookFuncKind
|
||||
|
||||
// Fill in the variables into this interface and the rest is done
|
||||
// automatically using the reflect package.
|
||||
potential := []interface{}{f1, f2}
|
||||
|
||||
v := reflect.ValueOf(h)
|
||||
vt := v.Type()
|
||||
for _, raw := range potential {
|
||||
pt := reflect.ValueOf(raw).Type()
|
||||
if vt.ConvertibleTo(pt) {
|
||||
return v.Convert(pt).Interface()
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// DecodeHookExec executes the given decode hook. This should be used
|
||||
// since it'll naturally degrade to the older backwards compatible DecodeHookFunc
|
||||
// that took reflect.Kind instead of reflect.Type.
|
||||
func DecodeHookExec(
|
||||
raw DecodeHookFunc,
|
||||
from reflect.Type, to reflect.Type,
|
||||
data interface{}) (interface{}, error) {
|
||||
switch f := typedDecodeHook(raw).(type) {
|
||||
case DecodeHookFuncType:
|
||||
return f(from, to, data)
|
||||
case DecodeHookFuncKind:
|
||||
return f(from.Kind(), to.Kind(), data)
|
||||
default:
|
||||
return nil, errors.New("invalid decode hook signature")
|
||||
}
|
||||
}
|
||||
|
||||
// ComposeDecodeHookFunc creates a single DecodeHookFunc that
|
||||
// automatically composes multiple DecodeHookFuncs.
|
||||
//
|
||||
// The composed funcs are called in order, with the result of the
|
||||
// previous transformation.
|
||||
func ComposeDecodeHookFunc(fs ...DecodeHookFunc) DecodeHookFunc {
|
||||
return func(
|
||||
f reflect.Type,
|
||||
t reflect.Type,
|
||||
data interface{}) (interface{}, error) {
|
||||
var err error
|
||||
for _, f1 := range fs {
|
||||
data, err = DecodeHookExec(f1, f, t, data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Modify the from kind to be correct with the new data
|
||||
f = nil
|
||||
if val := reflect.ValueOf(data); val.IsValid() {
|
||||
f = val.Type()
|
||||
}
|
||||
}
|
||||
|
||||
return data, nil
|
||||
}
|
||||
}
|
||||
|
||||
// StringToSliceHookFunc returns a DecodeHookFunc that converts
|
||||
// string to []string by splitting on the given sep.
|
||||
func StringToSliceHookFunc(sep string) DecodeHookFunc {
|
||||
return func(
|
||||
f reflect.Kind,
|
||||
t reflect.Kind,
|
||||
data interface{}) (interface{}, error) {
|
||||
if f != reflect.String || t != reflect.Slice {
|
||||
return data, nil
|
||||
}
|
||||
|
||||
raw := data.(string)
|
||||
if raw == "" {
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
return strings.Split(raw, sep), nil
|
||||
}
|
||||
}
|
||||
|
||||
// StringToTimeDurationHookFunc returns a DecodeHookFunc that converts
|
||||
// strings to time.Duration.
|
||||
func StringToTimeDurationHookFunc() DecodeHookFunc {
|
||||
return func(
|
||||
f reflect.Type,
|
||||
t reflect.Type,
|
||||
data interface{}) (interface{}, error) {
|
||||
if f.Kind() != reflect.String {
|
||||
return data, nil
|
||||
}
|
||||
if t != reflect.TypeOf(time.Duration(5)) {
|
||||
return data, nil
|
||||
}
|
||||
|
||||
// Convert it by parsing
|
||||
return time.ParseDuration(data.(string))
|
||||
}
|
||||
}
|
||||
|
||||
// StringToTimeHookFunc returns a DecodeHookFunc that converts
|
||||
// strings to time.Time.
|
||||
func StringToTimeHookFunc(layout string) DecodeHookFunc {
|
||||
return func(
|
||||
f reflect.Type,
|
||||
t reflect.Type,
|
||||
data interface{}) (interface{}, error) {
|
||||
if f.Kind() != reflect.String {
|
||||
return data, nil
|
||||
}
|
||||
if t != reflect.TypeOf(time.Time{}) {
|
||||
return data, nil
|
||||
}
|
||||
|
||||
// Convert it by parsing
|
||||
return time.Parse(layout, data.(string))
|
||||
}
|
||||
}
|
||||
|
||||
// WeaklyTypedHook is a DecodeHookFunc which adds support for weak typing to
|
||||
// the decoder.
|
||||
//
|
||||
// Note that this is significantly different from the WeaklyTypedInput option
|
||||
// of the DecoderConfig.
|
||||
func WeaklyTypedHook(
|
||||
f reflect.Kind,
|
||||
t reflect.Kind,
|
||||
data interface{}) (interface{}, error) {
|
||||
dataVal := reflect.ValueOf(data)
|
||||
switch t {
|
||||
case reflect.String:
|
||||
switch f {
|
||||
case reflect.Bool:
|
||||
if dataVal.Bool() {
|
||||
return "1", nil
|
||||
}
|
||||
return "0", nil
|
||||
case reflect.Float32:
|
||||
return strconv.FormatFloat(dataVal.Float(), 'f', -1, 64), nil
|
||||
case reflect.Int:
|
||||
return strconv.FormatInt(dataVal.Int(), 10), nil
|
||||
case reflect.Slice:
|
||||
dataType := dataVal.Type()
|
||||
elemKind := dataType.Elem().Kind()
|
||||
if elemKind == reflect.Uint8 {
|
||||
return string(dataVal.Interface().([]uint8)), nil
|
||||
}
|
||||
case reflect.Uint:
|
||||
return strconv.FormatUint(dataVal.Uint(), 10), nil
|
||||
}
|
||||
}
|
||||
|
||||
return data, nil
|
||||
}
|
50
vendor/github.com/mitchellh/mapstructure/error.go
generated
vendored
Normal file
50
vendor/github.com/mitchellh/mapstructure/error.go
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
package mapstructure
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Error implements the error interface and can represents multiple
|
||||
// errors that occur in the course of a single decode.
|
||||
type Error struct {
|
||||
Errors []string
|
||||
}
|
||||
|
||||
func (e *Error) Error() string {
|
||||
points := make([]string, len(e.Errors))
|
||||
for i, err := range e.Errors {
|
||||
points[i] = fmt.Sprintf("* %s", err)
|
||||
}
|
||||
|
||||
sort.Strings(points)
|
||||
return fmt.Sprintf(
|
||||
"%d error(s) decoding:\n\n%s",
|
||||
len(e.Errors), strings.Join(points, "\n"))
|
||||
}
|
||||
|
||||
// WrappedErrors implements the errwrap.Wrapper interface to make this
|
||||
// return value more useful with the errwrap and go-multierror libraries.
|
||||
func (e *Error) WrappedErrors() []error {
|
||||
if e == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
result := make([]error, len(e.Errors))
|
||||
for i, e := range e.Errors {
|
||||
result[i] = errors.New(e)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func appendErrors(errors []string, err error) []string {
|
||||
switch e := err.(type) {
|
||||
case *Error:
|
||||
return append(errors, e.Errors...)
|
||||
default:
|
||||
return append(errors, e.Error())
|
||||
}
|
||||
}
|
1043
vendor/github.com/mitchellh/mapstructure/mapstructure.go
generated
vendored
Normal file
1043
vendor/github.com/mitchellh/mapstructure/mapstructure.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
13
vendor/vendor.json
vendored
Normal file
13
vendor/vendor.json
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"comment": "",
|
||||
"ignore": "test",
|
||||
"package": [
|
||||
{
|
||||
"checksumSHA1": "Yvzge1YQcD/wSDXLD5qNHqmI/0s=",
|
||||
"path": "github.com/mitchellh/mapstructure",
|
||||
"revision": "00c29f56e2386353d58c599509e8dc3801b0d716",
|
||||
"revisionTime": "2018-02-20T23:01:11Z"
|
||||
}
|
||||
],
|
||||
"rootPath": "github.com/gfleury/go-bitbucket-v1"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user