Loading dependency_list_export.go +5 −13 Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ package gitlab import ( "bytes" "fmt" "io" "net/http" ) Loading Loading @@ -100,19 +99,12 @@ func (s *DependencyListExportService) GetDependencyListExport(id int64, options } func (s *DependencyListExportService) DownloadDependencyListExport(id int64, options ...RequestOptionFunc) (io.Reader, *Response, error) { // GET /dependency_list_exports/:id/download downloadExportPath := fmt.Sprintf("dependency_list_exports/%d/download", id) req, err := s.client.NewRequest(http.MethodGet, downloadExportPath, nil, options) if err != nil { return nil, nil, err } var sbomBuffer bytes.Buffer resp, err := s.client.Do(req, &sbomBuffer) buf, resp, err := do[bytes.Buffer](s.client, withPath("dependency_list_exports/%d/download", id), withRequestOpts(options...), ) if err != nil { return nil, resp, err } return &sbomBuffer, resp, nil return &buf, resp, nil } generic_packages.go +4 −20 Original line number Diff line number Diff line Loading @@ -148,28 +148,12 @@ func (s *GenericPackagesService) PublishPackageFile(pid any, packageName, packag // GitLab docs: // https://docs.gitlab.com/user/packages/generic_packages/#download-a-single-file func (s *GenericPackagesService) DownloadPackageFile(pid any, packageName, packageVersion, fileName string, options ...RequestOptionFunc) ([]byte, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf( "projects/%s/packages/generic/%s/%s/%s", PathEscape(project), PathEscape(packageName), PathEscape(packageVersion), PathEscape(fileName), buf, resp, err := do[bytes.Buffer](s.client, withPath("projects/%s/packages/generic/%s/%s/%s", ProjectID{pid}, packageName, packageVersion, fileName), withRequestOpts(options...), ) req, err := s.client.NewRequest(http.MethodGet, u, nil, options) if err != nil { return nil, nil, err } var f bytes.Buffer resp, err := s.client.Do(req, &f) if err != nil { return nil, resp, err } return f.Bytes(), resp, err return buf.Bytes(), resp, nil } gitlab.go +6 −2 Original line number Diff line number Diff line Loading @@ -963,8 +963,12 @@ func (c *Client) NewRequestToURL(method string, u *url.URL, opt any, options []R } } // Set the request specific headers. maps.Copy(req.Header, reqHeaders) // Set the request specific headers if they don't yet exist. for k, v := range reqHeaders { if _, ok := req.Header[k]; !ok { req.Header[k] = v } } return req, nil } Loading group_import_export.go +5 −15 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ package gitlab import ( "bytes" "errors" "fmt" "io" "mime/multipart" "net/http" Loading Loading @@ -65,23 +64,14 @@ func (s *GroupImportExportService) ScheduleExport(gid any, options ...RequestOpt // GitLab API docs: // https://docs.gitlab.com/api/group_import_export/#export-download func (s *GroupImportExportService) ExportDownload(gid any, options ...RequestOptionFunc) (*bytes.Reader, *Response, error) { group, err := parseID(gid) if err != nil { return nil, nil, err } req, err := s.client.NewRequest(http.MethodGet, fmt.Sprintf("groups/%s/export/download", group), nil, options) if err != nil { return nil, nil, err } exportDownload := new(bytes.Buffer) resp, err := s.client.Do(req, exportDownload) buf, resp, err := do[bytes.Buffer](s.client, withPath("groups/%s/export/download", GroupID{gid}), withRequestOpts(options...), ) if err != nil { return nil, resp, err } return bytes.NewReader(exportDownload.Bytes()), resp, err return bytes.NewReader(buf.Bytes()), resp, nil } // GroupImportFileOptions represents the available ImportFile() options. Loading group_relations_export.go +5 −18 Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ package gitlab import ( "bytes" "fmt" "net/http" "time" ) Loading Loading @@ -99,25 +98,13 @@ func (s *GroupRelationsExportService) ListExportStatus(gid any, opt *ListGroupRe } func (s *GroupRelationsExportService) ExportDownload(gid any, opt *GroupRelationsDownloadOptions, options ...RequestOptionFunc) (*bytes.Reader, *Response, error) { group, err := parseID(gid) if err != nil { return nil, nil, err } u := fmt.Sprintf("groups/%s/export_relations/download", PathEscape(group), buf, resp, err := do[bytes.Buffer](s.client, withPath("groups/%s/export_relations/download", GroupID{gid}), withAPIOpts(opt), withRequestOpts(options...), ) req, err := s.client.NewRequest(http.MethodGet, u, opt, options) if err != nil { return nil, nil, err } groupRelationsExportDownload := new(bytes.Buffer) resp, err := s.client.Do(req, groupRelationsExportDownload) if err != nil { return nil, resp, err } return bytes.NewReader(groupRelationsExportDownload.Bytes()), resp, err return bytes.NewReader(buf.Bytes()), resp, nil } Loading
dependency_list_export.go +5 −13 Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ package gitlab import ( "bytes" "fmt" "io" "net/http" ) Loading Loading @@ -100,19 +99,12 @@ func (s *DependencyListExportService) GetDependencyListExport(id int64, options } func (s *DependencyListExportService) DownloadDependencyListExport(id int64, options ...RequestOptionFunc) (io.Reader, *Response, error) { // GET /dependency_list_exports/:id/download downloadExportPath := fmt.Sprintf("dependency_list_exports/%d/download", id) req, err := s.client.NewRequest(http.MethodGet, downloadExportPath, nil, options) if err != nil { return nil, nil, err } var sbomBuffer bytes.Buffer resp, err := s.client.Do(req, &sbomBuffer) buf, resp, err := do[bytes.Buffer](s.client, withPath("dependency_list_exports/%d/download", id), withRequestOpts(options...), ) if err != nil { return nil, resp, err } return &sbomBuffer, resp, nil return &buf, resp, nil }
generic_packages.go +4 −20 Original line number Diff line number Diff line Loading @@ -148,28 +148,12 @@ func (s *GenericPackagesService) PublishPackageFile(pid any, packageName, packag // GitLab docs: // https://docs.gitlab.com/user/packages/generic_packages/#download-a-single-file func (s *GenericPackagesService) DownloadPackageFile(pid any, packageName, packageVersion, fileName string, options ...RequestOptionFunc) ([]byte, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf( "projects/%s/packages/generic/%s/%s/%s", PathEscape(project), PathEscape(packageName), PathEscape(packageVersion), PathEscape(fileName), buf, resp, err := do[bytes.Buffer](s.client, withPath("projects/%s/packages/generic/%s/%s/%s", ProjectID{pid}, packageName, packageVersion, fileName), withRequestOpts(options...), ) req, err := s.client.NewRequest(http.MethodGet, u, nil, options) if err != nil { return nil, nil, err } var f bytes.Buffer resp, err := s.client.Do(req, &f) if err != nil { return nil, resp, err } return f.Bytes(), resp, err return buf.Bytes(), resp, nil }
gitlab.go +6 −2 Original line number Diff line number Diff line Loading @@ -963,8 +963,12 @@ func (c *Client) NewRequestToURL(method string, u *url.URL, opt any, options []R } } // Set the request specific headers. maps.Copy(req.Header, reqHeaders) // Set the request specific headers if they don't yet exist. for k, v := range reqHeaders { if _, ok := req.Header[k]; !ok { req.Header[k] = v } } return req, nil } Loading
group_import_export.go +5 −15 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ package gitlab import ( "bytes" "errors" "fmt" "io" "mime/multipart" "net/http" Loading Loading @@ -65,23 +64,14 @@ func (s *GroupImportExportService) ScheduleExport(gid any, options ...RequestOpt // GitLab API docs: // https://docs.gitlab.com/api/group_import_export/#export-download func (s *GroupImportExportService) ExportDownload(gid any, options ...RequestOptionFunc) (*bytes.Reader, *Response, error) { group, err := parseID(gid) if err != nil { return nil, nil, err } req, err := s.client.NewRequest(http.MethodGet, fmt.Sprintf("groups/%s/export/download", group), nil, options) if err != nil { return nil, nil, err } exportDownload := new(bytes.Buffer) resp, err := s.client.Do(req, exportDownload) buf, resp, err := do[bytes.Buffer](s.client, withPath("groups/%s/export/download", GroupID{gid}), withRequestOpts(options...), ) if err != nil { return nil, resp, err } return bytes.NewReader(exportDownload.Bytes()), resp, err return bytes.NewReader(buf.Bytes()), resp, nil } // GroupImportFileOptions represents the available ImportFile() options. Loading
group_relations_export.go +5 −18 Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ package gitlab import ( "bytes" "fmt" "net/http" "time" ) Loading Loading @@ -99,25 +98,13 @@ func (s *GroupRelationsExportService) ListExportStatus(gid any, opt *ListGroupRe } func (s *GroupRelationsExportService) ExportDownload(gid any, opt *GroupRelationsDownloadOptions, options ...RequestOptionFunc) (*bytes.Reader, *Response, error) { group, err := parseID(gid) if err != nil { return nil, nil, err } u := fmt.Sprintf("groups/%s/export_relations/download", PathEscape(group), buf, resp, err := do[bytes.Buffer](s.client, withPath("groups/%s/export_relations/download", GroupID{gid}), withAPIOpts(opt), withRequestOpts(options...), ) req, err := s.client.NewRequest(http.MethodGet, u, opt, options) if err != nil { return nil, nil, err } groupRelationsExportDownload := new(bytes.Buffer) resp, err := s.client.Do(req, groupRelationsExportDownload) if err != nil { return nil, resp, err } return bytes.NewReader(groupRelationsExportDownload.Bytes()), resp, err return bytes.NewReader(buf.Bytes()), resp, nil }