| 39 | } |
| 40 | |
| 41 | func CollectProjects(taskCtx plugin.SubTaskContext) errors.Error { |
| 42 | data := taskCtx.GetData().(*TaigaTaskData) |
| 43 | logger := taskCtx.GetLogger() |
| 44 | logger.Info("collect projects") |
| 45 | |
| 46 | collector, err := api.NewApiCollector(api.ApiCollectorArgs{ |
| 47 | RawDataSubTaskArgs: api.RawDataSubTaskArgs{ |
| 48 | Ctx: taskCtx, |
| 49 | Params: TaigaApiParams{ |
| 50 | ConnectionId: data.Options.ConnectionId, |
| 51 | ProjectId: data.Options.ProjectId, |
| 52 | }, |
| 53 | Table: RAW_PROJECT_TABLE, |
| 54 | }, |
| 55 | ApiClient: data.ApiClient, |
| 56 | UrlTemplate: "projects/{{ .Params.ProjectId }}", |
| 57 | ResponseParser: func(res *http.Response) ([]json.RawMessage, errors.Error) { |
| 58 | var result json.RawMessage |
| 59 | err := api.UnmarshalResponse(res, &result) |
| 60 | if err != nil { |
| 61 | return nil, err |
| 62 | } |
| 63 | return []json.RawMessage{result}, nil |
| 64 | }, |
| 65 | }) |
| 66 | if err != nil { |
| 67 | logger.Error(err, "collect project error") |
| 68 | return err |
| 69 | } |
| 70 | return collector.Execute() |
| 71 | } |
| 72 | |
| 73 | type TaigaApiParams struct { |
| 74 | ConnectionId uint64 |