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

List entities in namespace(s) #111

Merged
merged 35 commits into from
Jul 2, 2024

Conversation

CasperWA
Copy link
Collaborator

@CasperWA CasperWA commented Apr 9, 2024

Closes #107

Add a new list CLI command group that adds two sub-commands: entities and namespaces.

list entities will list all Entities in a given NAMESPACE.
If a NAMESPACE argument is not given, the "core" namespace will be used by default.
It has the option --all-namespaces/-a to list all Entities in all namespaces.

list namespaces will list all namespaces as fully resolved URLs.

A new /_api router has been added to the service, it includes a GET /entities endpoint, which accepts multiple namespace query parameters, and will collect and return all entities in the given namespace(s). It also includes a GET /namespaces endpoint to return a list of all fully resolved namespaces the current service has entities in.


To do:

  • Test new CLI commands.
  • "Negative" tests for the CLI commands.
  • Test new router and endpoints.
  • "Negative" tests for the new router and endpoints.
  • Test new CLI command utility functions.

This endpoint is to return a list of entities from the desired
namespace(s). Namespace(s) can be requested through the `namespace`
query parameter, e.g.,
`/_api/entities?namespace="testing"&namespace="my/project"`.
Copy link

codecov bot commented Apr 9, 2024

Codecov Report

Attention: Patch coverage is 98.66071% with 3 lines in your changes missing coverage. Please review.

Project coverage is 93.08%. Comparing base (d505091) to head (fba2bbb).

Files Patch % Lines
entities_service/cli/commands/__init__.py 85.71% 1 Missing ⚠️
entities_service/service/backend/__init__.py 75.00% 1 Missing ⚠️
entities_service/service/backend/mongodb.py 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #111      +/-   ##
==========================================
+ Coverage   92.20%   93.08%   +0.88%     
==========================================
  Files          27       29       +2     
  Lines        1373     1577     +204     
==========================================
+ Hits         1266     1468     +202     
- Misses        107      109       +2     
Flag Coverage Δ
docker 81.29% <88.39%> (+1.24%) ⬆️
local 92.26% <98.66%> (+1.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@CasperWA CasperWA marked this pull request as draft April 9, 2024 13:48
CasperWA and others added 26 commits April 9, 2024 23:27
This is to be able to list namespaces as well.
Avoid adding __init__() for backends, instead use _initialize() (used to
be initialize()).
list namespaces

Will list all the namespaces as a full namespace, valid to be a value in
an entity under the namespace key.

list entities

Will list all entities for a given namespace or multiple namespaces or
all namespaces depending on the provided arguments (if any) or if the
`-a/--all` option is provided.

This has all been made possible through the (normally hidden) endpoints
`/_api/namespaces` and `/_api/entities`. Both are GET endpoints.

The endpoints will list all namespaces or all entities with a given list
of namespaces (provided through the query parameter 'namespace', may be
supplied multiple times - or no times).
This needs to be fixed concerning entity validation, since these are
hard-coded with the onto-ns.com namespace.
The main issue here is the monkeypatch of CONFIG.base_url for a live
backend, which is done in order to point to the localhost deployment,
while also using the original namespace of onto-ns.com.
Integrate utility functions better with the existing code base.
Utilize abstract methods in the magic methods for the Backend class.
For new API endpoints and new for service utils.py file.
@CasperWA CasperWA marked this pull request as ready for review July 1, 2024 15:30
@CasperWA CasperWA requested a review from Treesarj July 1, 2024 15:30
@CasperWA CasperWA merged commit 1fd928a into main Jul 2, 2024
19 checks passed
@CasperWA CasperWA deleted the cwa/close-107-list-entities-in-namespace branch July 2, 2024 13:14
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.

✨ List and report on entities in (specific) namespace
2 participants