~gophers/goose/unstable-001

« back to all changes in this revision

Viewing changes to client/client.go

MergeĀ ~wallyworld/goose/client-using-identity-cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
        goosehttp "launchpad.net/goose/http"
9
9
        "launchpad.net/goose/identity"
10
10
        "net/http"
11
 
        "net/url"
12
11
)
13
12
 
14
13
const (
30
29
)
31
30
 
32
31
type OpenStackClient struct {
33
 
        client *goosehttp.GooseHTTPClient
 
32
        client *goosehttp.Client
34
33
 
35
34
        creds *identity.Credentials
36
35
        auth  identity.Authenticator
42
41
        UserId      string
43
42
}
44
43
 
45
 
func NewOpenStackClient(creds *identity.Credentials, auth_method int) *OpenStackClient {
 
44
func NewOpenStackClient(creds *identity.Credentials, auth_method identity.AuthMethod) *OpenStackClient {
46
45
        client := OpenStackClient{creds: creds}
47
46
        client.creds.URL = client.creds.URL + OS_API_TOKENS
48
47
        switch auth_method {
49
48
        default:
50
49
                panic(fmt.Errorf("Invalid identity authorisation method: %d", auth_method))
51
 
        case identity.AUTH_LEGACY:
 
50
        case identity.AuthLegacy:
52
51
                client.auth = &identity.Legacy{}
53
 
        case identity.AUTH_USERPASS:
 
52
        case identity.AuthUserPass:
54
53
                client.auth = &identity.UserPass{}
55
54
        }
56
55
        return &client
63
62
        }
64
63
        authDetails, err := c.auth.Auth(c.creds)
65
64
        if err != nil {
66
 
                gooseerrors.AddErrorContext(&err, "authentication failed")
 
65
                err = gooseerrors.AddContext(err, "authentication failed")
67
66
                return
68
67
        }
69
68
 
98
97
                Flavors []Entity
99
98
        }
100
99
        requestData := goosehttp.RequestData{RespValue: &resp}
101
 
        err = c.authRequest(GET, "compute", OS_API_FLAVORS, nil, &requestData)
102
 
        if err != nil {
103
 
                gooseerrors.AddErrorContext(&err, "failed to get list of flavors")
104
 
                return
105
 
        }
106
 
 
107
 
        return resp.Flavors, nil
 
100
        err = c.sendRequest(GET, "compute", OS_API_FLAVORS, &requestData, "failed to get list of flavors")
 
101
        return resp.Flavors, err
108
102
}
109
103
 
110
104
type FlavorDetail struct {
122
116
                Flavors []FlavorDetail
123
117
        }
124
118
        requestData := goosehttp.RequestData{RespValue: &resp}
125
 
        err = c.authRequest(GET, "compute", OS_API_FLAVORS_DETAIL, nil, &requestData)
126
 
        if err != nil {
127
 
                gooseerrors.AddErrorContext(&err, "failed to get list of flavors details")
128
 
                return
129
 
        }
130
 
 
131
 
        return resp.Flavors, nil
 
119
        err = c.sendRequest(GET, "compute", OS_API_FLAVORS_DETAIL, &requestData,
 
120
                "failed to get list of flavors details")
 
121
        return resp.Flavors, err
132
122
}
133
123
 
134
124
func (c *OpenStackClient) ListServers() (servers []Entity, err error) {
137
127
                Servers []Entity
138
128
        }
139
129
        requestData := goosehttp.RequestData{RespValue: &resp, ExpectedStatus: []int{http.StatusOK}}
140
 
        err = c.authRequest(GET, "compute", OS_API_SERVERS, nil, &requestData)
141
 
        if err != nil {
142
 
                gooseerrors.AddErrorContext(&err, "failed to get list of servers")
143
 
                return
144
 
        }
145
 
        return resp.Servers, nil
 
130
        err = c.sendRequest(GET, "compute", OS_API_SERVERS, &requestData,
 
131
                "failed to get list of servers")
 
132
        return resp.Servers, err
146
133
}
147
134
 
148
135
type ServerDetail struct {
168
155
                Servers []ServerDetail
169
156
        }
170
157
        requestData := goosehttp.RequestData{RespValue: &resp}
171
 
        err = c.authRequest(GET, "compute", OS_API_SERVERS_DETAIL, nil, &requestData)
172
 
        if err != nil {
173
 
                gooseerrors.AddErrorContext(&err, "failed to get list of servers details")
174
 
                return
175
 
        }
176
 
 
177
 
        return resp.Servers, nil
 
158
        err = c.sendRequest(GET, "compute", OS_API_SERVERS_DETAIL, &requestData,
 
159
                "failed to get list of servers details")
 
160
        return resp.Servers, err
178
161
}
179
162
 
180
163
func (c *OpenStackClient) GetServer(serverId string) (ServerDetail, error) {
184
167
        }
185
168
        url := fmt.Sprintf("%s/%s", OS_API_SERVERS, serverId)
186
169
        requestData := goosehttp.RequestData{RespValue: &resp}
187
 
        err := c.authRequest(GET, "compute", url, nil, &requestData)
188
 
        if err != nil {
189
 
                gooseerrors.AddErrorContext(&err, "failed to get details for serverId=%s", serverId)
190
 
                return ServerDetail{}, err
191
 
        }
192
 
 
193
 
        return resp.Server, nil
 
170
        err := c.sendRequest(GET, "compute", url, &requestData,
 
171
                "failed to get details for serverId=%s", serverId)
 
172
        return resp.Server, err
194
173
}
195
174
 
196
 
func (c *OpenStackClient) DeleteServer(serverId string) error {
 
175
func (c *OpenStackClient) DeleteServer(serverId string) (err error) {
197
176
 
198
177
        var resp struct {
199
178
                Server ServerDetail
200
179
        }
201
180
        url := fmt.Sprintf("%s/%s", OS_API_SERVERS, serverId)
202
181
        requestData := goosehttp.RequestData{RespValue: &resp, ExpectedStatus: []int{http.StatusNoContent}}
203
 
        err := c.authRequest(DELETE, "compute", url, nil, &requestData)
204
 
        if err != nil {
205
 
                gooseerrors.AddErrorContext(&err, "failed to delete server with serverId=%s", serverId)
206
 
                return err
207
 
        }
208
 
 
209
 
        return nil
 
182
        err = c.sendRequest(DELETE, "compute", url, &requestData,
 
183
                "failed to delete server with serverId=%s", serverId)
 
184
        return
210
185
}
211
186
 
212
187
type RunServerOpts struct {
231
206
                req.Server.UserData = &encoded
232
207
        }
233
208
        requestData := goosehttp.RequestData{ReqValue: req, ExpectedStatus: []int{http.StatusAccepted}}
234
 
        err = c.authRequest(POST, "compute", OS_API_SERVERS, nil, &requestData)
235
 
        if err != nil {
236
 
                gooseerrors.AddErrorContext(&err, "failed to run a server with %#v", opts)
237
 
        }
238
 
 
 
209
        err = c.sendRequest(POST, "compute", OS_API_SERVERS, &requestData,
 
210
                "failed to run a server with %#v", opts)
239
211
        return
240
212
}
241
213
 
263
235
                Groups []SecurityGroup `json:"security_groups"`
264
236
        }
265
237
        requestData := goosehttp.RequestData{RespValue: &resp}
266
 
        err = c.authRequest(GET, "compute", OS_API_SECURITY_GROUPS, nil, &requestData)
267
 
        if err != nil {
268
 
                gooseerrors.AddErrorContext(&err, "failed to list security groups")
269
 
                return nil, err
270
 
        }
271
 
 
272
 
        return resp.Groups, nil
 
238
        err = c.sendRequest(GET, "compute", OS_API_SECURITY_GROUPS, &requestData,
 
239
                "failed to list security groups")
 
240
        return resp.Groups, err
273
241
}
274
242
 
275
243
func (c *OpenStackClient) GetServerSecurityGroups(serverId string) (groups []SecurityGroup, err error) {
279
247
        }
280
248
        url := fmt.Sprintf("%s/%s/%s", OS_API_SERVERS, serverId, OS_API_SECURITY_GROUPS)
281
249
        requestData := goosehttp.RequestData{RespValue: &resp}
282
 
        err = c.authRequest(GET, "compute", url, nil, &requestData)
283
 
        if err != nil {
284
 
                gooseerrors.AddErrorContext(&err, "failed to list server (%s) security groups", serverId)
285
 
                return nil, err
286
 
        }
287
 
 
288
 
        return resp.Groups, nil
 
250
        err = c.sendRequest(GET, "compute", url, &requestData,
 
251
                "failed to list server (%s) security groups", serverId)
 
252
        return resp.Groups, err
289
253
}
290
254
 
291
255
func (c *OpenStackClient) CreateSecurityGroup(name, description string) (group SecurityGroup, err error) {
303
267
                SecurityGroup SecurityGroup `json:"security_group"`
304
268
        }
305
269
        requestData := goosehttp.RequestData{ReqValue: req, RespValue: &resp, ExpectedStatus: []int{http.StatusOK}}
306
 
        err = c.authRequest(POST, "compute", OS_API_SECURITY_GROUPS, nil, &requestData)
307
 
        if err != nil {
308
 
                gooseerrors.AddErrorContext(&err, "failed to create a security group with name=%s", name)
309
 
        }
310
 
        group = resp.SecurityGroup
311
 
 
312
 
        return
 
270
        err = c.sendRequest(POST, "compute", OS_API_SECURITY_GROUPS, &requestData,
 
271
                "failed to create a security group with name=%s", name)
 
272
        return resp.SecurityGroup, err
313
273
}
314
274
 
315
275
func (c *OpenStackClient) DeleteSecurityGroup(groupId int) (err error) {
316
276
 
317
277
        url := fmt.Sprintf("%s/%d", OS_API_SECURITY_GROUPS, groupId)
318
278
        requestData := goosehttp.RequestData{ExpectedStatus: []int{http.StatusAccepted}}
319
 
        err = c.authRequest(DELETE, "compute", url, nil, &requestData)
320
 
        if err != nil {
321
 
                gooseerrors.AddErrorContext(&err, "failed to delete a security group with id=%d", groupId)
322
 
        }
323
 
 
 
279
        err = c.sendRequest(DELETE, "compute", url, &requestData,
 
280
                "failed to delete a security group with id=%d", groupId)
324
281
        return
325
282
}
326
283
 
345
302
        }
346
303
 
347
304
        requestData := goosehttp.RequestData{ReqValue: req, RespValue: &resp}
348
 
        err = c.authRequest(POST, "compute", OS_API_SECURITY_GROUP_RULES, nil, &requestData)
349
 
        if err != nil {
350
 
                gooseerrors.AddErrorContext(&err, "failed to create a rule for the security group with id=%s", ruleInfo.GroupId)
351
 
        }
352
 
 
 
305
        err = c.sendRequest(POST, "compute", OS_API_SECURITY_GROUP_RULES, &requestData,
 
306
                "failed to create a rule for the security group with id=%s", ruleInfo.GroupId)
353
307
        return resp.SecurityGroupRule, err
354
308
}
355
309
 
357
311
 
358
312
        url := fmt.Sprintf("%s/%d", OS_API_SECURITY_GROUP_RULES, ruleId)
359
313
        requestData := goosehttp.RequestData{ExpectedStatus: []int{http.StatusAccepted}}
360
 
        err = c.authRequest(DELETE, "compute", url, nil, &requestData)
361
 
        if err != nil {
362
 
                gooseerrors.AddErrorContext(&err, "failed to delete a security group rule with id=%d", ruleId)
363
 
        }
364
 
 
 
314
        err = c.sendRequest(DELETE, "compute", url, &requestData,
 
315
                "failed to delete a security group rule with id=%d", ruleId)
365
316
        return
366
317
}
367
318
 
376
327
 
377
328
        url := fmt.Sprintf("%s/%s/action", OS_API_SERVERS, serverId)
378
329
        requestData := goosehttp.RequestData{ReqValue: req, ExpectedStatus: []int{http.StatusAccepted}}
379
 
        err = c.authRequest(POST, "compute", url, nil, &requestData)
380
 
        if err != nil {
381
 
                gooseerrors.AddErrorContext(&err, "failed to add security group '%s' from server with id=%s", groupName, serverId)
382
 
        }
 
330
        err = c.sendRequest(POST, "compute", url, &requestData,
 
331
                "failed to add security group '%s' from server with id=%s", groupName, serverId)
383
332
        return
384
333
}
385
334
 
394
343
 
395
344
        url := fmt.Sprintf("%s/%s/action", OS_API_SERVERS, serverId)
396
345
        requestData := goosehttp.RequestData{ReqValue: req, ExpectedStatus: []int{http.StatusAccepted}}
397
 
        err = c.authRequest(POST, "compute", url, nil, &requestData)
398
 
        if err != nil {
399
 
                gooseerrors.AddErrorContext(&err, "failed to remove security group '%s' from server with id=%s", groupName, serverId)
400
 
        }
 
346
        err = c.sendRequest(POST, "compute", url, &requestData,
 
347
                "failed to remove security group '%s' from server with id=%s", groupName, serverId)
401
348
        return
402
349
}
403
350
 
416
363
        }
417
364
 
418
365
        requestData := goosehttp.RequestData{RespValue: &resp}
419
 
        err = c.authRequest(GET, "compute", OS_API_FLOATING_IPS, nil, &requestData)
420
 
        if err != nil {
421
 
                gooseerrors.AddErrorContext(&err, "failed to list floating ips")
422
 
        }
423
 
 
 
366
        err = c.sendRequest(GET, "compute", OS_API_FLOATING_IPS, &requestData,
 
367
                "failed to list floating ips")
424
368
        return resp.FloatingIPs, err
425
369
}
426
370
 
432
376
 
433
377
        url := fmt.Sprintf("%s/%d", OS_API_FLOATING_IPS, ipId)
434
378
        requestData := goosehttp.RequestData{RespValue: &resp}
435
 
        err = c.authRequest(GET, "compute", url, nil, &requestData)
436
 
        if err != nil {
437
 
                gooseerrors.AddErrorContext(&err, "failed to get floating ip %d details", ipId)
438
 
        }
439
 
 
 
379
        err = c.sendRequest(GET, "compute", url, &requestData,
 
380
                "failed to get floating ip %d details", ipId)
440
381
        return resp.FloatingIP, err
441
382
}
442
383
 
447
388
        }
448
389
 
449
390
        requestData := goosehttp.RequestData{RespValue: &resp}
450
 
        err = c.authRequest(POST, "compute", OS_API_FLOATING_IPS, nil, &requestData)
451
 
        if err != nil {
452
 
                gooseerrors.AddErrorContext(&err, "failed to allocate a floating ip")
453
 
        }
454
 
 
 
391
        err = c.sendRequest(POST, "compute", OS_API_FLOATING_IPS, &requestData,
 
392
                "failed to allocate a floating ip")
455
393
        return resp.FloatingIP, err
456
394
}
457
395
 
459
397
 
460
398
        url := fmt.Sprintf("%s/%d", OS_API_FLOATING_IPS, ipId)
461
399
        requestData := goosehttp.RequestData{ExpectedStatus: []int{http.StatusAccepted}}
462
 
        err = c.authRequest(DELETE, "compute", url, nil, &requestData)
463
 
        if err != nil {
464
 
                gooseerrors.AddErrorContext(&err, "failed to delete floating ip %d details", ipId)
465
 
        }
466
 
 
 
400
        err = c.sendRequest(DELETE, "compute", url, &requestData,
 
401
                "failed to delete floating ip %d details", ipId)
467
402
        return
468
403
}
469
404
 
478
413
 
479
414
        url := fmt.Sprintf("%s/%s/action", OS_API_SERVERS, serverId)
480
415
        requestData := goosehttp.RequestData{ReqValue: req, ExpectedStatus: []int{http.StatusAccepted}}
481
 
        err = c.authRequest(POST, "compute", url, nil, &requestData)
482
 
        if err != nil {
483
 
                gooseerrors.AddErrorContext(&err, "failed to add floating ip %s to server %s", address, serverId)
484
 
        }
485
 
 
 
416
        err = c.sendRequest(POST, "compute", url, &requestData,
 
417
                "failed to add floating ip %s to server %s", address, serverId)
486
418
        return
487
419
}
488
420
 
497
429
 
498
430
        url := fmt.Sprintf("%s/%s/action", OS_API_SERVERS, serverId)
499
431
        requestData := goosehttp.RequestData{ReqValue: req, ExpectedStatus: []int{http.StatusAccepted}}
500
 
        err = c.authRequest(POST, "compute", url, nil, &requestData)
501
 
        if err != nil {
502
 
                gooseerrors.AddErrorContext(&err, "failed to remove floating ip %s to server %s", address, serverId)
503
 
        }
504
 
 
 
432
        err = c.sendRequest(POST, "compute", url, &requestData,
 
433
                "failed to remove floating ip %s to server %s", address, serverId)
505
434
        return
506
435
}
507
436
 
514
443
        headers.Add("X-Container-Read", ".r:*")
515
444
        url := fmt.Sprintf("/%s", containerName)
516
445
        requestData := goosehttp.RequestData{ReqHeaders: headers, ExpectedStatus: []int{http.StatusAccepted, http.StatusCreated}}
517
 
        err = c.authRequest(PUT, "object-store", url, nil, &requestData)
518
 
        if err != nil {
519
 
                gooseerrors.AddErrorContext(&err, "failed to create container %s.", containerName)
520
 
        }
521
 
 
 
446
        err = c.sendRequest(PUT, "object-store", url, &requestData,
 
447
                "failed to create container %s.", containerName)
522
448
        return
523
449
}
524
450
 
526
452
 
527
453
        url := fmt.Sprintf("/%s", containerName)
528
454
        requestData := goosehttp.RequestData{ExpectedStatus: []int{http.StatusNoContent}}
529
 
        err = c.authRequest(DELETE, "object-store", url, nil, &requestData)
530
 
        if err != nil {
531
 
                gooseerrors.AddErrorContext(&err, "failed to delete container %s.", containerName)
532
 
        }
533
 
 
 
455
        err = c.sendRequest(DELETE, "object-store", url, &requestData,
 
456
                "failed to delete container %s.", containerName)
534
457
        return
535
458
}
536
459
 
537
460
func (c *OpenStackClient) PublicObjectURL(containerName, objectName string) (url string, err error) {
538
461
        path := fmt.Sprintf("/%s/%s", containerName, objectName)
539
 
        return c.makeUrl("object-store", []string{path}, nil)
 
462
        return c.makeServiceURL("object-store", []string{path})
540
463
}
541
464
 
542
465
func (c *OpenStackClient) HeadObject(containerName, objectName string) (headers http.Header, err error) {
546
469
                return nil, err
547
470
        }
548
471
        requestData := goosehttp.RequestData{ReqHeaders: headers, ExpectedStatus: []int{http.StatusOK}}
549
 
        err = c.authRequest(HEAD, "object-store", url, nil, &requestData)
550
 
        if err != nil {
551
 
                gooseerrors.AddErrorContext(&err, "failed to HEAD object %s from container %s", objectName, containerName)
552
 
                return nil, err
553
 
        }
554
 
        return headers, nil
 
472
        err = c.sendRequest(HEAD, "object-store", url, &requestData,
 
473
                "failed to HEAD object %s from container %s", objectName, containerName)
 
474
        return headers, err
555
475
}
556
476
 
557
477
func (c *OpenStackClient) GetObject(containerName, objectName string) (obj []byte, err error) {
561
481
                return nil, err
562
482
        }
563
483
        requestData := goosehttp.RequestData{RespData: &obj, ExpectedStatus: []int{http.StatusOK}}
564
 
        err = c.authBinaryRequest(GET, "object-store", url, nil, &requestData)
565
 
        if err != nil {
566
 
                gooseerrors.AddErrorContext(&err, "failed to GET object %s content from container %s", objectName, containerName)
567
 
                return nil, err
568
 
        }
569
 
        return obj, nil
 
484
        err = c.sendRequest(GET, "object-store", url, &requestData,
 
485
                "failed to GET object %s content from container %s", objectName, containerName)
 
486
        return obj, err
570
487
}
571
488
 
572
489
func (c *OpenStackClient) DeleteObject(containerName, objectName string) (err error) {
576
493
                return err
577
494
        }
578
495
        requestData := goosehttp.RequestData{ExpectedStatus: []int{http.StatusAccepted}}
579
 
        err = c.authRequest(DELETE, "object-store", url, nil, &requestData)
580
 
        if err != nil {
581
 
                gooseerrors.AddErrorContext(&err, "failed to DELETE object %s content from container %s", objectName, containerName)
582
 
        }
 
496
        err = c.sendRequest(DELETE, "object-store", url, &requestData,
 
497
                "failed to DELETE object %s content from container %s", objectName, containerName)
583
498
        return err
584
499
}
585
500
 
590
505
                return err
591
506
        }
592
507
        requestData := goosehttp.RequestData{ReqData: data, ExpectedStatus: []int{http.StatusAccepted}}
593
 
        err = c.authBinaryRequest(PUT, "object-store", url, nil, &requestData)
594
 
        if err != nil {
595
 
                gooseerrors.AddErrorContext(&err, "failed to PUT object %s content from container %s", objectName, containerName)
596
 
        }
 
508
        err = c.sendRequest(PUT, "object-store", url, &requestData,
 
509
                "failed to PUT object %s content from container %s", objectName, containerName)
597
510
        return err
598
511
}
599
512
 
600
513
////////////////////////////////////////////////////////////////////////
601
514
// Private helpers
602
515
 
603
 
// makeUrl prepares a full URL to a service endpoint, with optional
604
 
// URL parts, appended to it and optional query string params. It
605
 
// uses the first endpoint it can find for the given service type
606
 
func (c *OpenStackClient) makeUrl(serviceType string, parts []string, params url.Values) (string, error) {
 
516
// makeServiceURL prepares a full URL to a service endpoint, with optional
 
517
// URL parts. It uses the first endpoint it can find for the given service type.
 
518
func (c *OpenStackClient) makeServiceURL(serviceType string, parts []string) (string, error) {
607
519
        url, ok := c.ServiceURLs[serviceType]
608
520
        if !ok {
609
521
                return "", errors.New("no endpoints known for service type: " + serviceType)
611
523
        for _, part := range parts {
612
524
                url += part
613
525
        }
614
 
        if params != nil {
615
 
                url += "?" + params.Encode()
616
 
        }
617
526
        return url, nil
618
527
}
619
528
 
620
 
func (c *OpenStackClient) setupRequest(svcType, apiCall string, params url.Values, requestData *goosehttp.RequestData) (url string, err error) {
 
529
func (c *OpenStackClient) sendRequest(method, svcType, apiCall string, requestData *goosehttp.RequestData,
 
530
        context string, contextArgs ...interface{}) (err error) {
621
531
        if !c.IsAuthenticated() {
622
 
                return "", errors.New("not authenticated")
 
532
                err = gooseerrors.AddContext(errors.New("not authenticated"), context, contextArgs...)
 
533
                return
623
534
        }
624
535
 
625
 
        url, err = c.makeUrl(svcType, []string{apiCall}, params)
 
536
        url, err := c.makeServiceURL(svcType, []string{apiCall})
626
537
        if err != nil {
627
 
                gooseerrors.AddErrorContext(&err, "cannot find a '%s' node endpoint", svcType)
 
538
                err = gooseerrors.AddContext(err, "cannot find a '%s' node endpoint", svcType)
628
539
                return
629
540
        }
630
541
 
631
542
        if c.client == nil {
632
 
                c.client = &goosehttp.GooseHTTPClient{http.Client{CheckRedirect: nil}}
633
 
        }
634
 
 
635
 
        if requestData.ReqHeaders == nil {
636
 
                requestData.ReqHeaders = make(http.Header)
637
 
        }
638
 
        requestData.ReqHeaders.Add("X-Auth-Token", c.Token)
639
 
        return
640
 
}
641
 
 
642
 
func (c *OpenStackClient) authRequest(method, svcType, apiCall string, params url.Values, requestData *goosehttp.RequestData) (err error) {
643
 
        url, err := c.setupRequest(svcType, apiCall, params, requestData)
644
 
        if err != nil {
645
 
                return
646
 
        }
647
 
        err = c.client.JsonRequest(method, url, requestData)
648
 
        return
649
 
}
650
 
 
651
 
func (c *OpenStackClient) authBinaryRequest(method, svcType, apiCall string, params url.Values, requestData *goosehttp.RequestData) (err error) {
652
 
        url, err := c.setupRequest(svcType, apiCall, params, requestData)
653
 
        if err != nil {
654
 
                return
655
 
        }
656
 
        err = c.client.BinaryRequest(method, url, requestData)
 
543
                c.client = &goosehttp.Client{http.Client{CheckRedirect: nil}, c.Token}
 
544
        }
 
545
        if requestData.ReqValue != nil || requestData.RespValue != nil {
 
546
                err = c.client.JsonRequest(method, url, requestData)
 
547
        } else {
 
548
                err = c.client.BinaryRequest(method, url, requestData)
 
549
        }
 
550
        if err != nil {
 
551
                err = gooseerrors.AddContext(err, context, contextArgs...)
 
552
        }
657
553
        return
658
554
}