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

Use API generator. #549

Closed
wants to merge 3 commits into from
Closed

Conversation

dblock
Copy link
Member

@dblock dblock commented Oct 24, 2023

Description

Finishes #434 and #543.

Introduces a way to override API spec.

Issues Resolved

List any issues this PR will resolve, e.g. Closes [...].

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@dblock dblock force-pushed the use-api-generator branch from 65fe746 to 376d641 Compare October 24, 2023 15:18
@codecov
Copy link

codecov bot commented Oct 24, 2023

Codecov Report

Merging #549 (f7cbc6b) into main (627e717) will increase coverage by 0.13%.
The diff coverage is 50.76%.

@@            Coverage Diff             @@
##             main     #549      +/-   ##
==========================================
+ Coverage   70.68%   70.81%   +0.13%     
==========================================
  Files          83       85       +2     
  Lines        7862     7793      -69     
==========================================
- Hits         5557     5519      -38     
+ Misses       2305     2274      -31     
Files Coverage Δ
opensearchpy/_async/client/cat.py 65.78% <ø> (ø)
opensearchpy/_async/client/cluster.py 51.76% <100.00%> (ø)
opensearchpy/_async/client/dangling_indices.py 53.33% <ø> (ø)
opensearchpy/_async/client/indices.py 46.22% <ø> (+0.51%) ⬆️
opensearchpy/_async/client/ingest.py 50.00% <ø> (ø)
opensearchpy/_async/client/nodes.py 63.15% <ø> (ø)
opensearchpy/_async/client/snapshot.py 40.67% <100.00%> (+0.05%) ⬆️
opensearchpy/_async/client/tasks.py 64.28% <ø> (ø)
opensearchpy/client/cat.py 65.78% <ø> (ø)
opensearchpy/client/cluster.py 56.47% <100.00%> (ø)
... and 13 more

@dblock dblock marked this pull request as draft October 24, 2023 15:25
@dblock
Copy link
Member Author

dblock commented Oct 24, 2023

@saimedhi When running the generator we end up with 1 failing test that calls put_mapping with an index name that is not optional extracted from the path. Looks like OpenSearch supports _all, and the Python code gladly facilitates that by overriding the implementation and setting the value. We also need to override the method definition so that index = None. I couldn't find a way to do it, so I came up with patching the OpenAPI spec. Not sure whether this is the right approach?

@saimedhi
Copy link
Collaborator

@saimedhi When running the generator we end up with 1 failing test that calls put_mapping with an index name that is not optional extracted from the path. Looks like OpenSearch supports _all, and the Python code gladly facilitates that by overriding the implementation and setting the value. We also need to override the method definition so that index = None. I couldn't find a way to do it, so I came up with patching the OpenAPI spec. Not sure whether this is the right approach?

Thank you @dblock, for working on this. Can I take it from here? For put_mapping, alternative approach is to use the below code in the generator.

        if namespace == "indices" and name == "put_mapping":
            api["url"]["paths"][0]["parts"]["index"].update({"required": False})

@dblock
Copy link
Member Author

dblock commented Oct 24, 2023

@saimedhi When running the generator we end up with 1 failing test that calls put_mapping with an index name that is not optional extracted from the path. Looks like OpenSearch supports _all, and the Python code gladly facilitates that by overriding the implementation and setting the value. We also need to override the method definition so that index = None. I couldn't find a way to do it, so I came up with patching the OpenAPI spec. Not sure whether this is the right approach?

Thank you @dblock, for working on this. Can I take it from here? For put_mapping, alternative approach is to use the below code in the generator.

        if namespace == "indices" and name == "put_mapping":
            api["url"]["paths"][0]["parts"]["index"].update({"required": False})

Yes of course. I think my version of patching the API definition is a bit more generic :)

@dblock
Copy link
Member Author

dblock commented Oct 24, 2023

Will close this one, feel free to take any parts of it @saimedhi into #543.

@dblock dblock closed this Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants