-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #110 from ctreminiom/feature/long-task-archive_
Feature/long task archive
- Loading branch information
Showing
9 changed files
with
621 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package confluence | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"github.com/ctreminiom/go-atlassian/pkg/infra/models" | ||
"net/http" | ||
"net/url" | ||
"strconv" | ||
) | ||
|
||
type LongTaskService struct{ client *Client } | ||
|
||
// Gets returns information about all active long-running tasks (e.g. space export), | ||
// such as how long each task has been running and the percentage of each task that has completed. | ||
// Docs: https://docs.go-atlassian.io/confluence-cloud/long-task#get-long-running-tasks | ||
func (l *LongTaskService) Gets(ctx context.Context, start, limit int) (result *models.LongTaskPageScheme, | ||
response *ResponseScheme, err error) { | ||
|
||
query := url.Values{} | ||
query.Add("start", strconv.Itoa(start)) | ||
query.Add("limit", strconv.Itoa(limit)) | ||
|
||
var endpoint = fmt.Sprintf("/wiki/rest/api/longtask?%v", query.Encode()) | ||
|
||
request, err := l.client.newRequest(ctx, http.MethodGet, endpoint, nil) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
request.Header.Set("Accept", "application/json") | ||
|
||
response, err = l.client.Call(request, &result) | ||
if err != nil { | ||
return nil, response, err | ||
} | ||
|
||
return | ||
} | ||
|
||
// Get returns information about an active long-running task (e.g. space export), such as how long it has been running | ||
//and the percentage of the task that has completed. | ||
// Docs: https://docs.go-atlassian.io/confluence-cloud/long-task#get-long-running-task | ||
func (l *LongTaskService) Get(ctx context.Context, taskID string) (result *models.LongTaskScheme, response *ResponseScheme, | ||
err error) { | ||
|
||
var endpoint = fmt.Sprintf("/wiki/rest/api/longtask/%v", taskID) | ||
|
||
request, err := l.client.newRequest(ctx, http.MethodGet, endpoint, nil) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
request.Header.Set("Accept", "application/json") | ||
|
||
response, err = l.client.Call(request, &result) | ||
if err != nil { | ||
return nil, response, err | ||
} | ||
|
||
return | ||
} |
Oops, something went wrong.