Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config option to override the payer namespace for REST requests. #5105

Merged
merged 13 commits into from
Jun 19, 2024

Conversation

teo-tsirpanis
Copy link
Member

@teo-tsirpanis teo-tsirpanis commented Jun 19, 2024

SC-49142

This PR introduces a new config option that allows users to set the namespace to charge for REST requests when it cannot be automatically determined or when the user needs to set a specific override.

Big thanks to @Shelnutt2 for implementing this. I added a test and made some small changes on top of it.


TYPE: CONFIG
DESC: Add rest.payer_namespace config option to set the namespace to be charged for REST requests.

@teo-tsirpanis teo-tsirpanis requested a review from a team as a code owner June 19, 2024 13:44
@teo-tsirpanis teo-tsirpanis changed the title Payer namespace Add config option to override the payer namespace for REST requests. Jun 19, 2024
Comment on lines 141 to 142
// We copy because the [] operator is not const-qualified.
auto extra_headers = resources.rest_client()->extra_headers();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vector::at is const-qualified.

test/src/unit-curl.cc Outdated Show resolved Hide resolved
Shelnutt2 and others added 11 commits June 19, 2024 17:21
Similar to S3 custom header support this PR adds support for customer
header in REST request. This allows users to set header via a config
parameter instead of the current `tildb_context_set_tag`. The context
set tag does not work in all cases because its not always possible to
use the same context, i.e SOMA and VCF python APIs can't pass a
TileDB-Py ctx to their respective C++ code.
Co-authored-by: eric-hughes-tiledb <82400964+eric-hughes-tiledb@users.noreply.github.com>
This is a new config that allows users to set the namespace to charge
for requests when it cannot be automatically determined or when the user
needs to set a specific override.
Co-authored-by: eric-hughes-tiledb <82400964+eric-hughes-tiledb@users.noreply.github.com>
Copy link
Member

@ihnorton ihnorton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and confirmed -- succeeds with a non-default namespace I have access to, and fails with an invalid namespace (and I see the X-payer header in logs). Thanks for the quick turnaround.

In [1]: import tiledb, numpy as np, tiledb.cloud

In [2]: tiledb.default_ctx(tiledb.cloud.Ctx().config().dict() | {"rest.payer_namespace": "foobar"})
Out[2]: tiledb.Ctx() [see Ctx.config() for configuration]

In [3]: a = tiledb.open("tiledb://ihnorton/<array>")
TileDBError: [TileDB::REST] Error: Error submitting query to REST; server returned no data. Curl error: Error in libcurl POST operation: libcurl error message 'CURLE_OK'; HTTP code 401; server response data '{"code":147,"message":"You are not allowed to charge queries to foobar","request_id":"965a4a52-c66a-467d-8372-d5556d85d082"}'.

@KiterLuc KiterLuc dismissed eric-hughes-tiledb’s stale review June 19, 2024 17:08

All changes addressed.

@KiterLuc KiterLuc merged commit bdfc19c into dev Jun 19, 2024
61 checks passed
@KiterLuc KiterLuc deleted the payer-namespace branch June 19, 2024 17:08
KiterLuc added a commit that referenced this pull request Jun 19, 2024
…5105)

[SC-49142](https://app.shortcut.com/tiledb-inc/story/49142/add-support-for-rest-x-payer-via-config)

This PR introduces a new config option that allows users to set the
namespace to charge for REST requests when it cannot be automatically
determined or when the user needs to set a specific override.

Big thanks to @Shelnutt2 for implementing this. I added a test and made
some small changes on top of it.

---
TYPE: CONFIG
DESC: Add `rest.payer_namespace` config option to set the namespace to
be charged for REST requests.

---------

Co-authored-by: Seth Shelnutt <seth@tiledb.io>
Co-authored-by: KiterLuc <67824247+KiterLuc@users.noreply.github.com>
Co-authored-by: eric-hughes-tiledb <82400964+eric-hughes-tiledb@users.noreply.github.com>
Co-authored-by: Luc Rancourt <lucrancourt@gmail.com>
KiterLuc added a commit that referenced this pull request Jun 19, 2024
…5105)

[SC-49142](https://app.shortcut.com/tiledb-inc/story/49142/add-support-for-rest-x-payer-via-config)

This PR introduces a new config option that allows users to set the
namespace to charge for REST requests when it cannot be automatically
determined or when the user needs to set a specific override.

Big thanks to @Shelnutt2 for implementing this. I added a test and made
some small changes on top of it.

---
TYPE: CONFIG
DESC: Add `rest.payer_namespace` config option to set the namespace to
be charged for REST requests.

---------

Co-authored-by: Seth Shelnutt <seth@tiledb.io>
Co-authored-by: KiterLuc <67824247+KiterLuc@users.noreply.github.com>
Co-authored-by: eric-hughes-tiledb <82400964+eric-hughes-tiledb@users.noreply.github.com>
Co-authored-by: Luc Rancourt <lucrancourt@gmail.com>
KiterLuc added a commit that referenced this pull request Jun 19, 2024
…pace for REST requests. (#5105) (#5127)

Backport bdfc19c from #5105.

---
TYPE: CONFIG
DESC: Add `rest.payer_namespace` config option to set the namespace to
be charged for REST requests.

Co-authored-by: Theodore Tsirpanis <theodore.tsirpanis@tiledb.com>
Co-authored-by: Seth Shelnutt <seth@tiledb.io>
Co-authored-by: eric-hughes-tiledb <82400964+eric-hughes-tiledb@users.noreply.github.com>
ihnorton pushed a commit that referenced this pull request Jun 20, 2024
…pace for REST requests. (#5105) (#5126)

Backport bdfc19c from #5105.

---
TYPE: CONFIG
DESC: Add `rest.payer_namespace` config option to set the namespace to
be charged for REST requests.

Co-authored-by: Theodore Tsirpanis <theodore.tsirpanis@tiledb.com>
Co-authored-by: Seth Shelnutt <seth@tiledb.io>
Co-authored-by: eric-hughes-tiledb <82400964+eric-hughes-tiledb@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants