diff options
| author | Stefan Majewsky <stefan.majewsky@sap.com> | 2024-07-08 15:43:52 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-08 15:43:52 +0200 |
| commit | 4fac97b5e944ce70cdca3679f5c2b1eef9b83952 (patch) | |
| tree | fcf486f49df855f2803981c753ed775b1305f6c8 /account.go | |
| parent | 5a783c56a98c225569abfa6fb12fdf55297fee9e (diff) | |
| parent | b7683ab8dcdeca10ff52d626a285edcf7c1db719 (diff) | |
| download | go-schwift-4fac97b5e944ce70cdca3679f5c2b1eef9b83952.tar.gz | |
Merge pull request #19 from SuperSandro2000/context
Remove context from struct, add ctx as first args to many functions
Diffstat (limited to 'account.go')
| -rw-r--r-- | account.go | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -98,7 +98,7 @@ func (a *Account) Backend() Backend { // // WARNING: This method is not thread-safe. Calling it concurrently on the same // object results in undefined behavior. -func (a *Account) Headers() (AccountHeaders, error) { +func (a *Account) Headers(ctx context.Context) (AccountHeaders, error) { if a.headers != nil { return *a.headers, nil } @@ -106,7 +106,7 @@ func (a *Account) Headers() (AccountHeaders, error) { resp, err := Request{ Method: "HEAD", ExpectStatusCodes: []int{204}, - }.Do(a.backend) + }.Do(ctx, a.backend) if err != nil { return AccountHeaders{}, err } @@ -134,12 +134,12 @@ func (a *Account) Invalidate() { // attribute take precedence over those in opts.Headers. // // A successful POST request implies Invalidate() since it may change metadata. -func (a *Account) Update(headers AccountHeaders, opts *RequestOptions) error { +func (a *Account) Update(ctx context.Context, headers AccountHeaders, opts *RequestOptions) error { resp, err := Request{ Method: "POST", Options: cloneRequestOptions(opts, headers.Headers), ExpectStatusCodes: []int{204}, - }.Do(a.backend) + }.Do(ctx, a.backend) if err == nil { a.Invalidate() resp.Body.Close() @@ -151,13 +151,13 @@ func (a *Account) Update(headers AccountHeaders, opts *RequestOptions) error { // available to reseller admins, not to regular users. // // A successful PUT request implies Invalidate() since it may change metadata. -func (a *Account) Create(opts *RequestOptions) error { +func (a *Account) Create(ctx context.Context, opts *RequestOptions) error { resp, err := Request{ Method: "PUT", Options: opts, ExpectStatusCodes: []int{201, 202}, DrainResponseBody: true, - }.Do(a.backend) + }.Do(ctx, a.backend) if err == nil { a.Invalidate() resp.Body.Close() |
