• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

UiPath / uipathcli / 13944984167

19 Mar 2025 11:04AM UTC coverage: 90.471% (+0.4%) from 90.112%
13944984167

push

github

web-flow
Merge pull request #166 from UiPath/feature/api-package

Add new api package with orchestrator and du client

260 of 291 new or added lines in 21 files covered. (89.35%)

1 existing line in 1 file now uncovered.

5896 of 6517 relevant lines covered (90.47%)

1.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

81.22
/utils/api/orchestrator_client.go
1
package api
2

3
import (
4
        "bytes"
5
        "context"
6
        "encoding/json"
7
        "errors"
8
        "fmt"
9
        "io"
10
        "mime/multipart"
11
        "net/http"
12
        "net/textproto"
13
        "strconv"
14
        "time"
15

16
        "github.com/UiPath/uipathcli/auth"
17
        "github.com/UiPath/uipathcli/log"
18
        "github.com/UiPath/uipathcli/plugin"
19
        "github.com/UiPath/uipathcli/utils/network"
20
        "github.com/UiPath/uipathcli/utils/stream"
21
        "github.com/UiPath/uipathcli/utils/visualization"
22
)
23

24
var ErrPackageAlreadyExists = errors.New("Package already exists")
25

26
type OrchestratorClient struct {
27
        baseUri  string
28
        token    *auth.AuthToken
29
        debug    bool
30
        settings plugin.ExecutionSettings
31
        logger   log.Logger
32
}
33

34
func (c OrchestratorClient) GetSharedFolderId() (int, error) {
1✔
35
        request := c.createGetFolderRequest()
1✔
36
        client := network.NewHttpClient(c.logger, c.httpClientSettings())
1✔
37
        response, err := client.Send(request)
1✔
38
        if err != nil {
1✔
39
                return -1, err
×
40
        }
×
41
        defer response.Body.Close()
1✔
42
        body, err := io.ReadAll(response.Body)
1✔
43
        if err != nil {
1✔
44
                return -1, fmt.Errorf("Error reading response: %w", err)
×
45
        }
×
46
        if response.StatusCode != http.StatusOK {
2✔
47
                return -1, fmt.Errorf("Orchestrator returned status code '%v' and body '%v'", response.StatusCode, string(body))
1✔
48
        }
1✔
49

50
        var result getFoldersResponseJson
1✔
51
        err = json.Unmarshal(body, &result)
1✔
52
        if err != nil {
1✔
53
                return -1, fmt.Errorf("Orchestrator returned invalid response body '%v'", string(body))
×
54
        }
×
55
        folderId := c.findFolderId(result)
1✔
56
        if folderId == nil {
2✔
57
                return -1, fmt.Errorf("Could not find 'Shared' orchestrator folder.")
1✔
58
        }
1✔
59
        return *folderId, nil
1✔
60
}
61

62
func (c OrchestratorClient) createGetFolderRequest() *network.HttpRequest {
1✔
63
        uri := c.baseUri + "/odata/Folders"
1✔
64
        header := http.Header{
1✔
65
                "Content-Type": {"application/json"},
1✔
66
        }
1✔
67
        return network.NewHttpGetRequest(uri, c.toAuthorization(c.token), header)
1✔
68
}
1✔
69

70
func (c OrchestratorClient) findFolderId(result getFoldersResponseJson) *int {
1✔
71
        for _, value := range result.Value {
2✔
72
                if value.Name == "Shared" {
2✔
73
                        return &value.Id
1✔
74
                }
1✔
75
        }
76
        if len(result.Value) > 0 {
1✔
77
                return &result.Value[0].Id
×
78
        }
×
79
        return nil
1✔
80
}
81

82
func (c OrchestratorClient) Upload(file stream.Stream, uploadBar *visualization.ProgressBar) error {
1✔
83
        context, cancel := context.WithCancelCause(context.Background())
1✔
84
        request := c.createUploadRequest(file, uploadBar, cancel)
1✔
85
        client := network.NewHttpClient(c.logger, c.httpClientSettings())
1✔
86
        response, err := client.SendWithContext(request, context)
1✔
87
        if err != nil {
2✔
88
                return err
1✔
89
        }
1✔
90
        defer response.Body.Close()
1✔
91
        body, err := io.ReadAll(response.Body)
1✔
92
        if err != nil {
1✔
93
                return fmt.Errorf("Error reading response: %w", err)
×
94
        }
×
95
        if response.StatusCode == http.StatusConflict {
2✔
96
                return ErrPackageAlreadyExists
1✔
97
        }
1✔
98
        if response.StatusCode != http.StatusOK {
2✔
99
                return fmt.Errorf("Orchestrator returned status code '%v' and body '%v'", response.StatusCode, string(body))
1✔
100
        }
1✔
101
        return nil
1✔
102
}
103

104
func (c OrchestratorClient) createUploadRequest(file stream.Stream, uploadBar *visualization.ProgressBar, cancel context.CancelCauseFunc) *network.HttpRequest {
1✔
105
        bodyReader, bodyWriter := io.Pipe()
1✔
106
        streamSize, _ := file.Size()
1✔
107
        contentType := c.writeMultipartBody(bodyWriter, file, "application/octet-stream", cancel)
1✔
108
        uploadReader := c.progressReader("uploading...", "completing  ", bodyReader, streamSize, uploadBar)
1✔
109

1✔
110
        uri := c.baseUri + "/odata/Processes/UiPath.Server.Configuration.OData.UploadPackage"
1✔
111
        header := http.Header{
1✔
112
                "Content-Type": {contentType},
1✔
113
        }
1✔
114
        return network.NewHttpPostRequest(uri, c.toAuthorization(c.token), header, uploadReader, -1)
1✔
115
}
1✔
116

117
func (c OrchestratorClient) writeMultipartBody(bodyWriter *io.PipeWriter, stream stream.Stream, contentType string, cancel context.CancelCauseFunc) string {
1✔
118
        formWriter := multipart.NewWriter(bodyWriter)
1✔
119
        go func() {
2✔
120
                defer bodyWriter.Close()
1✔
121
                defer formWriter.Close()
1✔
122
                err := c.writeMultipartForm(formWriter, stream, contentType)
1✔
123
                if err != nil {
1✔
124
                        cancel(err)
×
125
                        return
×
126
                }
×
127
        }()
128
        return formWriter.FormDataContentType()
1✔
129
}
130

131
func (c OrchestratorClient) writeMultipartForm(writer *multipart.Writer, stream stream.Stream, contentType string) error {
1✔
132
        filePart := textproto.MIMEHeader{}
1✔
133
        filePart.Set("Content-Disposition", fmt.Sprintf(`form-data; name="file"; filename="%s"`, stream.Name()))
1✔
134
        filePart.Set("Content-Type", contentType)
1✔
135
        w, err := writer.CreatePart(filePart)
1✔
136
        if err != nil {
1✔
137
                return fmt.Errorf("Error creating form field 'file': %w", err)
×
138
        }
×
139
        data, err := stream.Data()
1✔
140
        if err != nil {
1✔
141
                return err
×
142
        }
×
143
        defer data.Close()
1✔
144
        _, err = io.Copy(w, data)
1✔
145
        if err != nil {
1✔
146
                return fmt.Errorf("Error writing form field 'file': %w", err)
×
147
        }
×
148
        return nil
1✔
149
}
150

151
func (c OrchestratorClient) GetReleases(folderId int, processKey string) ([]Release, error) {
1✔
152
        request := c.createGetReleasesRequest(folderId, processKey)
1✔
153
        client := network.NewHttpClient(c.logger, c.httpClientSettings())
1✔
154
        response, err := client.Send(request)
1✔
155
        if err != nil {
1✔
156
                return []Release{}, err
×
157
        }
×
158
        defer response.Body.Close()
1✔
159
        body, err := io.ReadAll(response.Body)
1✔
160
        if err != nil {
1✔
161
                return []Release{}, fmt.Errorf("Error reading response: %w", err)
×
162
        }
×
163
        if response.StatusCode != http.StatusOK {
2✔
164
                return []Release{}, fmt.Errorf("Orchestrator returned status code '%v' and body '%v'", response.StatusCode, string(body))
1✔
165
        }
1✔
166

167
        var result getReleasesResponseJson
1✔
168
        err = json.Unmarshal(body, &result)
1✔
169
        if err != nil {
1✔
170
                return []Release{}, fmt.Errorf("Orchestrator returned invalid response body '%v'", string(body))
×
171
        }
×
172
        return c.convertToReleases(result), nil
1✔
173
}
174

175
func (c OrchestratorClient) convertToReleases(json getReleasesResponseJson) []Release {
1✔
176
        releases := []Release{}
1✔
177
        for _, v := range json.Value {
2✔
178
                releases = append(releases, *NewRelease(v.Id, v.Name))
1✔
179
        }
1✔
180
        return releases
1✔
181
}
182

183
func (c OrchestratorClient) createGetReleasesRequest(folderId int, processKey string) *network.HttpRequest {
1✔
184
        uri := c.baseUri + "/odata/Releases?$filter=ProcessKey%20eq%20'" + processKey + "'"
1✔
185
        header := http.Header{
1✔
186
                "Content-Type":                {"application/json"},
1✔
187
                "X-Uipath-Organizationunitid": {strconv.Itoa(folderId)},
1✔
188
        }
1✔
189
        return network.NewHttpGetRequest(uri, c.toAuthorization(c.token), header)
1✔
190
}
1✔
191

192
func (c OrchestratorClient) CreateOrUpdateRelease(folderId int, processKey string, processVersion string) (int, error) {
1✔
193
        releases, err := c.GetReleases(folderId, processKey)
1✔
194
        if err != nil {
2✔
195
                return -1, err
1✔
196
        }
1✔
197
        if len(releases) > 0 {
2✔
198
                return c.UpdateRelease(folderId, releases[0].Id, processKey, processVersion)
1✔
199
        }
1✔
200
        return c.CreateRelease(folderId, processKey, processVersion)
1✔
201
}
202

203
func (c OrchestratorClient) CreateRelease(folderId int, processKey string, processVersion string) (int, error) {
1✔
204
        request, err := c.createNewReleaseRequest(folderId, processKey, processVersion)
1✔
205
        if err != nil {
1✔
206
                return -1, err
×
207
        }
×
208
        client := network.NewHttpClient(c.logger, c.httpClientSettings())
1✔
209
        response, err := client.Send(request)
1✔
210
        if err != nil {
1✔
211
                return -1, err
×
212
        }
×
213
        defer response.Body.Close()
1✔
214
        body, err := io.ReadAll(response.Body)
1✔
215
        if err != nil {
1✔
216
                return -1, fmt.Errorf("Error reading response: %w", err)
×
217
        }
×
218
        if response.StatusCode != http.StatusCreated {
1✔
219
                return -1, fmt.Errorf("Orchestrator returned status code '%v' and body '%v'", response.StatusCode, string(body))
×
220
        }
×
221

222
        var result createReleaseResponseJson
1✔
223
        err = json.Unmarshal(body, &result)
1✔
224
        if err != nil {
2✔
225
                return -1, fmt.Errorf("Orchestrator returned invalid response body '%v'", string(body))
1✔
226
        }
1✔
227
        return result.Id, nil
1✔
228
}
229

230
func (c OrchestratorClient) createNewReleaseRequest(folderId int, processKey string, processVersion string) (*network.HttpRequest, error) {
1✔
231
        json, err := json.Marshal(createReleaseRequestJson{
1✔
232
                Name:           processKey,
1✔
233
                ProcessKey:     processKey,
1✔
234
                ProcessVersion: processVersion,
1✔
235
        })
1✔
236
        if err != nil {
1✔
237
                return nil, err
×
238
        }
×
239
        uri := c.baseUri + "/odata/Releases"
1✔
240
        header := http.Header{
1✔
241
                "Content-Type":                {"application/json"},
1✔
242
                "X-Uipath-Organizationunitid": {strconv.Itoa(folderId)},
1✔
243
        }
1✔
244
        return network.NewHttpPostRequest(uri, c.toAuthorization(c.token), header, bytes.NewBuffer(json), -1), nil
1✔
245
}
246

247
func (c OrchestratorClient) UpdateRelease(folderId int, releaseId int, processKey string, processVersion string) (int, error) {
1✔
248
        request, err := c.createUpdateReleaseRequest(folderId, releaseId, processKey, processVersion)
1✔
249
        if err != nil {
1✔
250
                return -1, err
×
251
        }
×
252
        client := network.NewHttpClient(c.logger, c.httpClientSettings())
1✔
253
        response, err := client.Send(request)
1✔
254
        if err != nil {
1✔
255
                return -1, err
×
256
        }
×
257
        defer response.Body.Close()
1✔
258
        body, err := io.ReadAll(response.Body)
1✔
259
        if err != nil {
1✔
260
                return -1, fmt.Errorf("Error reading response: %w", err)
×
261
        }
×
262
        if response.StatusCode != http.StatusOK {
1✔
263
                return -1, fmt.Errorf("Orchestrator returned status code '%v' and body '%v'", response.StatusCode, string(body))
×
264
        }
×
265
        return releaseId, nil
1✔
266
}
267

268
func (c OrchestratorClient) createUpdateReleaseRequest(folderId int, releaseId int, processKey string, processVersion string) (*network.HttpRequest, error) {
1✔
269
        json, err := json.Marshal(createReleaseRequestJson{
1✔
270
                Name:           processKey,
1✔
271
                ProcessKey:     processKey,
1✔
272
                ProcessVersion: processVersion,
1✔
273
        })
1✔
274
        if err != nil {
1✔
275
                return nil, err
×
276
        }
×
277
        uri := c.baseUri + fmt.Sprintf("/odata/Releases(%d)", releaseId)
1✔
278
        header := http.Header{
1✔
279
                "Content-Type":                {"application/json"},
1✔
280
                "X-Uipath-Organizationunitid": {strconv.Itoa(folderId)},
1✔
281
        }
1✔
282
        return network.NewHttpPatchRequest(uri, c.toAuthorization(c.token), header, bytes.NewBuffer(json), -1), nil
1✔
283
}
284

285
func (c OrchestratorClient) CreateTestSet(folderId int, releaseId int, processVersion string) (int, error) {
1✔
286
        request, err := c.createTestSetRequest(folderId, releaseId, processVersion)
1✔
287
        if err != nil {
1✔
288
                return -1, err
×
289
        }
×
290
        client := network.NewHttpClient(c.logger, c.httpClientSettings())
1✔
291
        response, err := client.Send(request)
1✔
292
        if err != nil {
2✔
293
                return -1, err
1✔
294
        }
1✔
295
        defer response.Body.Close()
1✔
296
        body, err := io.ReadAll(response.Body)
1✔
297
        if err != nil {
1✔
298
                return -1, fmt.Errorf("Error reading response: %w", err)
×
299
        }
×
300
        if response.StatusCode != http.StatusCreated {
1✔
301
                return -1, fmt.Errorf("Orchestrator returned status code '%v' and body '%v'", response.StatusCode, string(body))
×
302
        }
×
303
        return strconv.Atoi(string(body))
1✔
304
}
305

306
func (c OrchestratorClient) createTestSetRequest(folderId int, releaseId int, processVersion string) (*network.HttpRequest, error) {
1✔
307
        json, err := json.Marshal(createTestSetRequestJson{
1✔
308
                ReleaseId:     releaseId,
1✔
309
                VersionNumber: processVersion,
1✔
310
        })
1✔
311
        if err != nil {
1✔
312
                return nil, err
×
313
        }
×
314
        uri := c.baseUri + "/api/TestAutomation/CreateTestSetForReleaseVersion"
1✔
315
        header := http.Header{
1✔
316
                "Content-Type":                {"application/json"},
1✔
317
                "X-Uipath-Organizationunitid": {strconv.Itoa(folderId)},
1✔
318
        }
1✔
319
        return network.NewHttpPostRequest(uri, c.toAuthorization(c.token), header, bytes.NewBuffer(json), -1), nil
1✔
320
}
321

322
func (c OrchestratorClient) ExecuteTestSet(folderId int, testSetId int) (int, error) {
1✔
323
        request := c.createExecuteTestSetRequest(folderId, testSetId)
1✔
324
        client := network.NewHttpClient(c.logger, c.httpClientSettings())
1✔
325
        response, err := client.Send(request)
1✔
326
        if err != nil {
2✔
327
                return -1, err
1✔
328
        }
1✔
329
        defer response.Body.Close()
1✔
330
        body, err := io.ReadAll(response.Body)
1✔
331
        if err != nil {
1✔
332
                return -1, fmt.Errorf("Error reading response: %w", err)
×
333
        }
×
334
        if response.StatusCode != http.StatusOK {
1✔
335
                return -1, fmt.Errorf("Orchestrator returned status code '%v' and body '%v'", response.StatusCode, string(body))
×
336
        }
×
337
        return strconv.Atoi(string(body))
1✔
338
}
339

340
func (c OrchestratorClient) createExecuteTestSetRequest(folderId int, testSetId int) *network.HttpRequest {
1✔
341
        uri := c.baseUri + fmt.Sprintf("/api/TestAutomation/StartTestSetExecution?testSetId=%d&triggerType=ExternalTool", testSetId)
1✔
342
        header := http.Header{
1✔
343
                "Content-Type":                {"application/json"},
1✔
344
                "X-Uipath-Organizationunitid": {strconv.Itoa(folderId)},
1✔
345
        }
1✔
346
        return network.NewHttpPostRequest(uri, c.toAuthorization(c.token), header, bytes.NewReader([]byte{}), -1)
1✔
347
}
1✔
348

349
func (c OrchestratorClient) WaitForTestExecutionToFinish(folderId int, executionId int, timeout time.Duration, statusFunc func(TestExecution)) (*TestExecution, error) {
1✔
350
        startTime := time.Now()
1✔
351
        for {
2✔
352
                execution, err := c.GetTestExecution(folderId, executionId)
1✔
353
                if err != nil {
1✔
354
                        return nil, err
×
355
                }
×
356
                statusFunc(*execution)
1✔
357
                if execution.IsCompleted() {
2✔
358
                        return execution, nil
1✔
359
                }
1✔
360
                if time.Since(startTime) >= timeout {
2✔
361
                        return nil, fmt.Errorf("Timeout waiting for test execution '%d' to finish.", executionId)
1✔
362
                }
1✔
363
                time.Sleep(1 * time.Second)
1✔
364
        }
365
}
366

367
func (c OrchestratorClient) GetTestExecution(folderId int, executionId int) (*TestExecution, error) {
1✔
368
        request := c.createGetTestExecutionRequest(folderId, executionId)
1✔
369
        client := network.NewHttpClient(c.logger, c.httpClientSettings())
1✔
370
        response, err := client.Send(request)
1✔
371
        if err != nil {
1✔
372
                return nil, err
×
373
        }
×
374
        defer response.Body.Close()
1✔
375
        body, err := io.ReadAll(response.Body)
1✔
376
        if err != nil {
1✔
377
                return nil, fmt.Errorf("Error reading response: %w", err)
×
378
        }
×
379
        if response.StatusCode != http.StatusOK {
1✔
380
                return nil, fmt.Errorf("Orchestrator returned status code '%v' and body '%v'", response.StatusCode, string(body))
×
381
        }
×
382

383
        var result getTestExecutionResponseJson
1✔
384
        err = json.Unmarshal(body, &result)
1✔
385
        if err != nil {
1✔
386
                return nil, fmt.Errorf("Orchestrator returned invalid response body '%v'", string(body))
×
387
        }
×
388
        return c.convertToTestExecution(result), nil
1✔
389
}
390

391
func (c OrchestratorClient) createGetTestExecutionRequest(folderId int, executionId int) *network.HttpRequest {
1✔
392
        uri := c.baseUri + fmt.Sprintf("/odata/TestSetExecutions(%d)?$expand=TestCaseExecutions($expand=TestCaseAssertions)", executionId)
1✔
393
        header := http.Header{
1✔
394
                "Content-Type":                {"application/json"},
1✔
395
                "X-Uipath-Organizationunitid": {strconv.Itoa(folderId)},
1✔
396
        }
1✔
397
        return network.NewHttpGetRequest(uri, c.toAuthorization(c.token), header)
1✔
398
}
1✔
399

400
func (c OrchestratorClient) GetReadUrl(folderId int, bucketId int, path string) (string, error) {
1✔
401
        request := c.createReadUrlRequest(folderId, bucketId, path)
1✔
402
        client := network.NewHttpClient(c.logger, c.httpClientSettings())
1✔
403
        response, err := client.Send(request)
1✔
404
        if err != nil {
1✔
NEW
405
                return "", fmt.Errorf("Error sending request: %w", err)
×
NEW
406
        }
×
407
        defer response.Body.Close()
1✔
408
        body, err := io.ReadAll(response.Body)
1✔
409
        if err != nil {
1✔
NEW
410
                return "", fmt.Errorf("Error reading response: %w", err)
×
NEW
411
        }
×
412
        if response.StatusCode != http.StatusOK {
2✔
413
                return "", fmt.Errorf("Orchestrator returned status code '%v' and body '%v'", response.StatusCode, string(body))
1✔
414
        }
1✔
415
        var result urlResponse
1✔
416
        err = json.Unmarshal(body, &result)
1✔
417
        if err != nil {
1✔
NEW
418
                return "", fmt.Errorf("Error parsing json response: %w", err)
×
NEW
419
        }
×
420
        return result.Uri, nil
1✔
421
}
422

423
func (c OrchestratorClient) createReadUrlRequest(folderId int, bucketId int, path string) *network.HttpRequest {
1✔
424
        uri := c.baseUri + fmt.Sprintf("/odata/Buckets(%d)/UiPath.Server.Configuration.OData.GetReadUri?path=%s", bucketId, path)
1✔
425
        header := http.Header{
1✔
426
                "X-UiPath-OrganizationUnitId": {fmt.Sprintf("%d", folderId)},
1✔
427
        }
1✔
428
        return network.NewHttpGetRequest(uri, c.toAuthorization(c.token), header)
1✔
429
}
1✔
430

431
func (c OrchestratorClient) GetWriteUrl(folderId int, bucketId int, path string) (string, error) {
1✔
432
        request := c.createWriteUrlRequest(folderId, bucketId, path)
1✔
433
        client := network.NewHttpClient(c.logger, c.httpClientSettings())
1✔
434
        response, err := client.Send(request)
1✔
435
        if err != nil {
1✔
NEW
436
                return "", err
×
NEW
437
        }
×
438
        defer response.Body.Close()
1✔
439
        body, err := io.ReadAll(response.Body)
1✔
440
        if err != nil {
1✔
NEW
441
                return "", fmt.Errorf("Error reading response: %w", err)
×
NEW
442
        }
×
443
        if response.StatusCode != http.StatusOK {
2✔
444
                return "", fmt.Errorf("Orchestrator returned status code '%v' and body '%v'", response.StatusCode, string(body))
1✔
445
        }
1✔
446
        var result urlResponse
1✔
447
        err = json.Unmarshal(body, &result)
1✔
448
        if err != nil {
1✔
NEW
449
                return "", fmt.Errorf("Error parsing json response: %w", err)
×
NEW
450
        }
×
451
        return result.Uri, nil
1✔
452
}
453

454
func (c OrchestratorClient) createWriteUrlRequest(folderId int, bucketId int, path string) *network.HttpRequest {
1✔
455
        uri := c.baseUri + fmt.Sprintf("/odata/Buckets(%d)/UiPath.Server.Configuration.OData.GetWriteUri?path=%s", bucketId, path)
1✔
456
        header := http.Header{
1✔
457
                "X-UiPath-OrganizationUnitId": {fmt.Sprintf("%d", folderId)},
1✔
458
        }
1✔
459
        return network.NewHttpGetRequest(uri, c.toAuthorization(c.token), header)
1✔
460
}
1✔
461

462
func (c OrchestratorClient) convertToTestExecution(json getTestExecutionResponseJson) *TestExecution {
1✔
463
        return NewTestExecution(
1✔
464
                json.Id,
1✔
465
                json.Status,
1✔
466
                json.TestSetId,
1✔
467
                json.Name,
1✔
468
                json.StartTime,
1✔
469
                json.EndTime,
1✔
470
                c.convertToTestCaseExecutions(json.TestCaseExecutions))
1✔
471
}
1✔
472

473
func (c OrchestratorClient) convertToTestCaseExecutions(json []testCaseExecutionJson) []TestCaseExecution {
1✔
474
        executions := []TestCaseExecution{}
1✔
475
        for _, v := range json {
2✔
476
                execution := NewTestCaseExecution(
1✔
477
                        v.Id,
1✔
478
                        v.Status,
1✔
479
                        v.TestCaseId,
1✔
480
                        v.EntryPointPath,
1✔
481
                        v.Info,
1✔
482
                        v.StartTime,
1✔
483
                        v.EndTime)
1✔
484
                executions = append(executions, *execution)
1✔
485
        }
1✔
486
        return executions
1✔
487
}
488

489
func (c OrchestratorClient) progressReader(text string, completedText string, reader io.Reader, length int64, progressBar *visualization.ProgressBar) io.Reader {
1✔
490
        if length < 10*1024*1024 {
2✔
491
                return reader
1✔
492
        }
1✔
493
        return visualization.NewProgressReader(reader, func(progress visualization.Progress) {
2✔
494
                displayText := text
1✔
495
                if progress.Completed {
2✔
496
                        displayText = completedText
1✔
497
                }
1✔
498
                progressBar.UpdateProgress(displayText, progress.BytesRead, length, progress.BytesPerSecond)
1✔
499
        })
500
}
501

502
func (c OrchestratorClient) httpClientSettings() network.HttpClientSettings {
1✔
503
        return *network.NewHttpClientSettings(
1✔
504
                c.debug,
1✔
505
                c.settings.OperationId,
1✔
506
                c.settings.Timeout,
1✔
507
                c.settings.MaxAttempts,
1✔
508
                c.settings.Insecure)
1✔
509
}
1✔
510

511
func (c OrchestratorClient) toAuthorization(token *auth.AuthToken) *network.Authorization {
1✔
512
        if token == nil {
2✔
513
                return nil
1✔
514
        }
1✔
NEW
515
        return network.NewAuthorization(token.Type, token.Value)
×
516
}
517

518
type createReleaseRequestJson struct {
519
        Name           string `json:"name"`
520
        ProcessKey     string `json:"processKey"`
521
        ProcessVersion string `json:"processVersion"`
522
}
523

524
type createTestSetRequestJson struct {
525
        ReleaseId     int    `json:"releaseId"`
526
        VersionNumber string `json:"versionNumber"`
527
}
528

529
type getFoldersResponseJson struct {
530
        Value []getFoldersResponseValueJson `json:"value"`
531
}
532

533
type getFoldersResponseValueJson struct {
534
        Id   int    `json:"Id"`
535
        Name string `json:"FullyQualifiedName"`
536
}
537

538
type getReleasesResponseJson struct {
539
        Value []getReleasesResponseValueJson `json:"value"`
540
}
541

542
type getReleasesResponseValueJson struct {
543
        Id   int    `json:"Id"`
544
        Name string `json:"Name"`
545
}
546

547
type createReleaseResponseJson struct {
548
        Id int `json:"id"`
549
}
550

551
type getTestExecutionResponseJson struct {
552
        Id                 int                     `json:"Id"`
553
        Status             string                  `json:"Status"`
554
        TestSetId          int                     `json:"TestSetId"`
555
        Name               string                  `json:"Name"`
556
        StartTime          time.Time               `json:"StartTime"`
557
        EndTime            time.Time               `json:"EndTime"`
558
        TestCaseExecutions []testCaseExecutionJson `json:"TestCaseExecutions"`
559
}
560

561
type testCaseExecutionJson struct {
562
        Id             int       `json:"Id"`
563
        Status         string    `json:"Status"`
564
        TestCaseId     int       `json:"TestCaseId"`
565
        EntryPointPath string    `json:"EntryPointPath"`
566
        Info           string    `json:"Info"`
567
        StartTime      time.Time `json:"StartTime"`
568
        EndTime        time.Time `json:"EndTime"`
569
}
570

571
type urlResponse struct {
572
        Uri string `json:"Uri"`
573
}
574

575
func NewOrchestratorClient(baseUri string, token *auth.AuthToken, debug bool, settings plugin.ExecutionSettings, logger log.Logger) *OrchestratorClient {
1✔
576
        return &OrchestratorClient{baseUri, token, debug, settings, logger}
1✔
577
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc