diff --git a/default_api.go b/default_api.go index 87149e7..528da38 100644 --- a/default_api.go +++ b/default_api.go @@ -8,6 +8,7 @@ import ( "encoding/json" "fmt" "io" + "io/ioutil" "net/url" "strings" @@ -3267,16 +3268,20 @@ func (a *DefaultApiService) GetApplicationProperties() (*APIResponse, error) { /* DefaultApiService Streams an archive of the repository's contents at the requested commit. If no <code>at=</code> commit is requested, an archive of the default branch is streamed. <p> The <code>filename=</code> query parameter may be used to specify the exact filename to include in the <code>\"Content-Disposition\"</code> header. If an explicit filename is not provided, one will be automatically generated based on what is being archived. Its format depends on the <code>at=</code> value: <ul> <li>No <code>at=</code> commit: <code>&lt;slug&gt;-&lt;default-branch-name&gt;@&lt;commit&gt;.&lt;format&gt;</code>; e.g. example-master@43c2f8a0fe8.zip</li> <li><code>at=sha</code>: <code>&lt;slug&gt;-&lt;at&gt;.&lt;format&gt;</code>; e.g. example-09bcbb00100cfbb5310fb6834a1d5ce6cac253e9.tar.gz</li> <li><code>at=branchOrTag</code>: <code>&lt;slug&gt;-&lt;branchOrTag&gt;@&lt;commit&gt;.&lt;format&gt;</code>; e.g. example-feature@bbb225f16e1.tar <ul> <li>If the branch or tag is qualified (e.g. <code>refs/heads/master</code>, the short name (<code>master</code>) will be included in the filename</li> <li>If the branch or tag's <i>short name</i> includes slashes (e.g. <code>release/4.6</code>), they will be converted to hyphens in the filename (<code>release-4.5</code>)</li> </ul> </li> </ul> <p> Archives may be requested in the following formats by adding the <code>format=</code> query parameter: <ul> <li><code>zip</code>: A zip file using standard compression (Default)</li> <li><code>tar</code>: An uncompressed tarball</li> <li><code>tar.gz</code> or <code>tgz</code>: A GZip-compressed tarball</li> </ul> The contents of the archive may be filtered by using the <code>path=</code> query parameter to specify paths to include. <code>path=</code> may be specified multiple times to include multiple paths. <p> The <code>prefix=</code> query parameter may be used to define a directory (or multiple directories) where the archive's contents should be placed. If the prefix does not end with <code>/</code>, one will be added automatically. The prefix is <i>always</i> treated as a directory; it is not possible to use it to prepend characters to the entries in the archive. <p> Archives of public repositories may be streamed by any authenticated or anonymous user. Streaming archives for non-public repositories requires an <i>authenticated user</i> with at least <b>REPO_READ</b> permission. - + * @param ctx context.Context for authentication, logging, tracing, etc. @param optional (nil or map[string]interface{}) with one or more of: @param "at" (string) the commit to stream an archive of; if not supplied, an archive of the default branch is streamed @param "filename" (string) a filename to include the \"Content-Disposition\" header @param "format" (string) the format to stream the archive in; must be one of: zip, tar, tar.gz or tgz @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 + @param "apibasepath" (string) defaults to "/api/1.0" - in some installations, the value is "/archive/latest". Used as part of the URL endpoint. Not used as an actual parameter + + @param writer Where the archive's content is streamed out. + +@return the size of the archive written out */ -func (a *DefaultApiService) GetArchive(project, repository string, localVarOptionals map[string]interface{}) (*APIResponse, error) { +func (a *DefaultApiService) GetArchive(project, repository string, localVarOptionals map[string]interface{}, writer io.Writer) (int64, error) { var ( localVarHTTPMethod = strings.ToUpper("Get") localVarPostBody interface{} @@ -3285,7 +3290,16 @@ func (a *DefaultApiService) GetArchive(project, repository string, localVarOptio ) // create path and map variables - localVarPath := a.client.cfg.BasePath + "/api/1.0/projects/{projectKey}/repos/{repositorySlug}/archive" + if err := typeCheckParameter(localVarOptionals["apibasepath"], "string", "apibasepath"); err != nil { + return 0, err + } + apibasepath, _ := localVarOptionals["apibasepath"].(string) + if apibasepath == "" { + apibasepath = "/api/1.0" + } + + //localVarPath := a.client.cfg.BasePath + "/api/1.0/projects/{projectKey}/repos/{repositorySlug}/archive" + localVarPath := a.client.cfg.BasePath + apibasepath + "/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) @@ -3294,19 +3308,19 @@ func (a *DefaultApiService) GetArchive(project, repository string, localVarOptio localVarFormParams := url.Values{} if err := typeCheckParameter(localVarOptionals["at"], "string", "at"); err != nil { - return nil, err + return 0, err } if err := typeCheckParameter(localVarOptionals["filename"], "string", "filename"); err != nil { - return nil, err + return 0, err } if err := typeCheckParameter(localVarOptionals["format"], "string", "format"); err != nil { - return nil, err + return 0, err } if err := typeCheckParameter(localVarOptionals["path"], "string", "path"); err != nil { - return nil, err + return 0, err } if err := typeCheckParameter(localVarOptionals["prefix"], "string", "prefix"); err != nil { - return nil, err + return 0, err } if localVarTempParam, localVarOk := localVarOptionals["at"].(string); localVarOk { @@ -3319,7 +3333,9 @@ func (a *DefaultApiService) GetArchive(project, repository string, localVarOptio localVarQueryParams.Add("format", parameterToString(localVarTempParam, "")) } if localVarTempParam, localVarOk := localVarOptionals["path"].(string); localVarOk { - localVarQueryParams.Add("path", parameterToString(localVarTempParam, "")) + for _, path := range strings.Split(parameterToString(localVarTempParam, ""), ",") { + localVarQueryParams.Add("path", path) + } } if localVarTempParam, localVarOk := localVarOptionals["prefix"].(string); localVarOk { localVarQueryParams.Add("prefix", parameterToString(localVarTempParam, "")) @@ -3343,20 +3359,19 @@ func (a *DefaultApiService) GetArchive(project, repository string, localVarOptio } r, err := a.client.prepareRequest(a.client.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return nil, err + return 0, err } localVarHTTPResponse, err := a.client.callAPI(r) if err != nil || localVarHTTPResponse == nil { - return NewAPIResponseWithError(localVarHTTPResponse, nil, err) + return 0, err } defer localVarHTTPResponse.Body.Close() if localVarHTTPResponse.StatusCode >= 300 { - bodyBytes, _ := io.ReadAll(localVarHTTPResponse.Body) - return NewAPIResponseWithError(localVarHTTPResponse, bodyBytes, reportError("Status: %v, Body: %s", localVarHTTPResponse.Status, bodyBytes)) + bodyBytes, _ := ioutil.ReadAll(localVarHTTPResponse.Body) + return 0, reportError("Status: %v, Body: %s", localVarHTTPResponse.Status, bodyBytes) } - - return NewRawAPIResponse(localVarHTTPResponse) + return io.Copy(writer, localVarHTTPResponse.Body) } /*