Skip to content

Commit

Permalink
Update search usage to avoid "beta" APIs (#823)
Browse files Browse the repository at this point in the history
* Update dependencies (via script)

Updates pinned globus-sdk and mypy to latest versions.
Also, remove explicit click dep from tox.ini, where it is stale.

* Update 'search index create|delete' to use v1 APIs

Upgrade from the /beta/ APIs to the v1 APIs, which are provided via
SDK methods in the latest release.

Because the SDK methods also come with mock data for testing, via
`globus_sdk._testing`, custom mocks for CLI testing can be removed and
replaced in this case.
  • Loading branch information
sirosen authored Jul 20, 2023
1 parent 12d27d9 commit 14bc46f
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 36 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def read_readme():
package_dir={"": "src"},
python_requires=">=3.7",
install_requires=[
"globus-sdk==3.23.0",
"globus-sdk==3.24.0",
"click>=8.0.0,<9",
"jmespath==1.0.1",
"packaging>=17.0",
Expand Down
5 changes: 2 additions & 3 deletions src/globus_cli/commands/search/index/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
def create_command(
*, login_manager: LoginManager, display_name: str, description: str
) -> None:
"""(BETA) Create a new Index"""
index_doc = {"display_name": display_name, "description": description}
"""Create a new Index"""
search_client = login_manager.get_search_client()
display(
search_client.post("/beta/index", data=index_doc),
search_client.create_index(display_name=display_name, description=description),
text_mode=TextMode.text_record,
fields=INDEX_FIELDS,
)
4 changes: 2 additions & 2 deletions src/globus_cli/commands/search/index/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
@LoginManager.requires_login("search")
@click.argument("INDEX_ID")
def delete_command(*, login_manager: LoginManager, index_id: str) -> None:
"""(BETA) Delete a Search Index"""
"""Delete a Search Index"""
search_client = login_manager.get_search_client()
display(
search_client.delete(f"/beta/index/{index_id}"),
search_client.delete_index(index_id),
simple_text=f"Index {index_id} is now marked for deletion.\n"
"It will be fully deleted after cleanup steps complete.",
)
25 changes: 0 additions & 25 deletions tests/files/api_fixtures/search.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -336,31 +336,6 @@ search:
"status": "open",
"subscription_id": null
}
- path: /beta/index
method: POST
json:
{
"@datatype": "GSearchIndex",
"@version": "2017-09-01",
"creation_date": "2018-04-20 19:23:46",
"description": "Example index of Cookery",
"display_name": "example_cookery",
"id": "6f831ac8-4c41-4812-b383-6fb04f8b9f9f",
"is_trial": false,
"max_size_in_mb": 1,
"num_entries": 0,
"num_subjects": 0,
"size_in_mb": 0,
"status": "open",
"subscription_id": null
}
- path: /beta/index/6f831ac8-4c41-4812-b383-6fb04f8b9f9f
method: DELETE
json:
{
"acknowledged": true,
"index_id": "6f831ac8-4c41-4812-b383-6fb04f8b9f9f"
}
- path: /v1/index_list
json:
{
Expand Down
6 changes: 3 additions & 3 deletions tests/functional/search/test_index.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from globus_sdk._testing import load_response_set
from globus_sdk._testing import load_response, load_response_set


def test_index_list(run_line):
Expand Down Expand Up @@ -28,7 +28,7 @@ def test_index_show(run_line):


def test_index_create(run_line):
meta = load_response_set("cli.search").metadata
meta = load_response("search.create_index").metadata
index_id = meta["index_id"]

run_line(
Expand All @@ -45,7 +45,7 @@ def test_index_create(run_line):


def test_index_delete(run_line):
meta = load_response_set("cli.search").metadata
meta = load_response("search.delete_index").metadata
index_id = meta["index_id"]

run_line(
Expand Down
3 changes: 1 addition & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ base_python =
python3.11
python3.10
deps =
click
mypy
mypy==1.4.1
types-jwt
types-requests
types-jmespath
Expand Down

0 comments on commit 14bc46f

Please sign in to comment.