Skip to content

Commit

Permalink
regenerating api spec, correcting parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
brandon-groundlight committed Dec 12, 2024
1 parent 4af4671 commit 028998a
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 14 deletions.
12 changes: 12 additions & 0 deletions generated/docs/ActionsApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,13 +296,23 @@ with groundlight_openapi_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = actions_api.ActionsApi(api_client)
detector_id = "detector_id_example" # str |
page = 1 # int | A page number within the paginated result set. (optional)
page_size = 1 # int | Number of results to return per page. (optional)

# example passing only required values which don't have defaults set
try:
api_response = api_instance.list_detector_rules(detector_id)
pprint(api_response)
except groundlight_openapi_client.ApiException as e:
print("Exception when calling ActionsApi->list_detector_rules: %s\n" % e)

# example passing only required values which don't have defaults set
# and optional values
try:
api_response = api_instance.list_detector_rules(detector_id, page=page, page_size=page_size)
pprint(api_response)
except groundlight_openapi_client.ApiException as e:
print("Exception when calling ActionsApi->list_detector_rules: %s\n" % e)
```


Expand All @@ -311,6 +321,8 @@ with groundlight_openapi_client.ApiClient(configuration) as api_client:
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**detector_id** | **str**| |
**page** | **int**| A page number within the paginated result set. | [optional]
**page_size** | **int**| Number of results to return per page. | [optional]

### Return type

Expand Down
6 changes: 3 additions & 3 deletions generated/docs/ImageQueriesApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,14 @@ configuration.api_key['ApiToken'] = 'YOUR_API_KEY'
with groundlight_openapi_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = image_queries_api.ImageQueriesApi(api_client)
detector_id = "detector_id_example" # str | Optionally filter image queries by detector ID. (optional)
page = 1 # int | A page number within the paginated result set. (optional)
page_size = 1 # int | Number of items to return per page. (optional)
predictor_id = "predictor_id_example" # str | Optionally filter image queries by detector ID. (optional)

# example passing only required values which don't have defaults set
# and optional values
try:
api_response = api_instance.list_image_queries(page=page, page_size=page_size, predictor_id=predictor_id)
api_response = api_instance.list_image_queries(detector_id=detector_id, page=page, page_size=page_size)
pprint(api_response)
except groundlight_openapi_client.ApiException as e:
print("Exception when calling ImageQueriesApi->list_image_queries: %s\n" % e)
Expand All @@ -219,9 +219,9 @@ with groundlight_openapi_client.ApiClient(configuration) as api_client:

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**detector_id** | **str**| Optionally filter image queries by detector ID. | [optional]
**page** | **int**| A page number within the paginated result set. | [optional]
**page_size** | **int**| Number of items to return per page. | [optional]
**predictor_id** | **str**| Optionally filter image queries by detector ID. | [optional]

### Return type

Expand Down
10 changes: 10 additions & 0 deletions generated/groundlight_openapi_client/api/actions_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ def __init__(self, api_client=None):
params_map={
"all": [
"detector_id",
"page",
"page_size",
],
"required": [
"detector_id",
Expand All @@ -186,12 +188,18 @@ def __init__(self, api_client=None):
"allowed_values": {},
"openapi_types": {
"detector_id": (str,),
"page": (int,),
"page_size": (int,),
},
"attribute_map": {
"detector_id": "detector_id",
"page": "page",
"page_size": "page_size",
},
"location_map": {
"detector_id": "path",
"page": "query",
"page_size": "query",
},
"collection_format_map": {},
},
Expand Down Expand Up @@ -434,6 +442,8 @@ def list_detector_rules(self, detector_id, **kwargs):
detector_id (str):
Keyword Args:
page (int): A page number within the paginated result set.. [optional]
page_size (int): Number of results to return per page.. [optional]
_return_http_data_only (bool): response data without head status
code and headers. Default is True.
_preload_content (bool): if False, the urllib3.HTTPResponse object
Expand Down
10 changes: 5 additions & 5 deletions generated/groundlight_openapi_client/api/image_queries_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ def __init__(self, api_client=None):
},
params_map={
"all": [
"detector_id",
"page",
"page_size",
"predictor_id",
],
"required": [],
"nullable": [],
Expand All @@ -140,19 +140,19 @@ def __init__(self, api_client=None):
"validations": {},
"allowed_values": {},
"openapi_types": {
"detector_id": (str,),
"page": (int,),
"page_size": (int,),
"predictor_id": (str,),
},
"attribute_map": {
"detector_id": "detector_id",
"page": "page",
"page_size": "page_size",
"predictor_id": "predictor_id",
},
"location_map": {
"detector_id": "query",
"page": "query",
"page_size": "query",
"predictor_id": "query",
},
"collection_format_map": {},
},
Expand Down Expand Up @@ -377,9 +377,9 @@ def list_image_queries(self, **kwargs):
Keyword Args:
detector_id (str): Optionally filter image queries by detector ID.. [optional]
page (int): A page number within the paginated result set.. [optional]
page_size (int): Number of items to return per page.. [optional]
predictor_id (str): Optionally filter image queries by detector ID.. [optional]
_return_http_data_only (bool): response data without head status
code and headers. Default is True.
_preload_content (bool): if False, the urllib3.HTTPResponse object
Expand Down
2 changes: 1 addition & 1 deletion generated/model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# generated by datamodel-codegen:
# filename: public-api.yaml
# timestamp: 2024-12-10T01:13:13+00:00
# timestamp: 2024-12-12T23:38:24+00:00

from __future__ import annotations

Expand Down
19 changes: 18 additions & 1 deletion spec/public-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ paths:
schema:
type: string
required: true
- name: page
required: false
in: query
description: A page number within the paginated result set.
schema:
type: integer
- name: page_size
required: false
in: query
description: Number of results to return per page.
schema:
type: integer
tags:
- actions
security:
Expand Down Expand Up @@ -313,6 +325,11 @@ paths:
operationId: List image queries
description: Retrieve a list of image-queries.
parameters:
- in: query
name: detector_id
schema:
type: string
description: Optionally filter image queries by detector ID.
- in: query
name: page
schema:
Expand Down Expand Up @@ -1457,4 +1474,4 @@ servers:
- url: https://device.positronix.ai/device-api
description: Device Prod
- url: https://device.integ.positronix.ai/device-api
description: Device Integ
description: Device Integ
15 changes: 11 additions & 4 deletions src/groundlight/experimental_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,25 +214,32 @@ def get_rule(self, action_id: int) -> Rule:
"""
return Rule.model_validate(self.actions_api.get_rule(action_id).to_dict())

def list_detector_rules(self, detector: Union[str, Detector]) -> List[Rule]:
def list_detector_rules(self, detector: Union[str, Detector], page=1, page_size=10) -> PaginatedRuleList:
"""
Gets all rules associated with the given detector.
Gets a paginated list of rules associated with the given detector.
**Example usage**::
gl = ExperimentalApi()
# Get all rules for a specific detector
rules = gl.list_detector_rules(det_mydetectorid)
for rule in rules:
for rule in rules.results:
print(f"Rule {rule.id}: {rule.name}")
# Get next page
next_page = gl.list_detector_rules(det_mydetectorid, page=2)
:param detector: the detector or detector_id to get the rules for
:param page: the page number to retrieve (default: 1)
:param page_size: the number of rules per page (default: 10)
:return: a list of Rule objects associated with the given detector
"""
if isinstance(detector, Detector):
detector = detector.id
return [Rule.model_validate(rule.to_dict()) for rule in self.actions_api.list_detector_rules(detector)]
return PaginatedRuleList.parse_obj(
self.actions_api.list_detector_rules(detector, page=page, page_size=page_size).to_dict()
)

def delete_rule(self, action_id: int) -> None:
"""
Expand Down
3 changes: 3 additions & 0 deletions test/unit/test_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ def test_delete_actions(gl_experimental: ExperimentalApi):
det = gl_experimental.get_or_create_detector(name, "test_query")
for i in range(num_test_rules):
_ = gl_experimental.create_rule(det, f"test_rule_{i}", "EMAIL", "[email protected]")
import IPython

IPython.embed()
rules = gl_experimental.list_detector_rules(det.id)
assert rules.count == num_test_rules
gl_experimental.delete_all_rules(det.id)
Expand Down

0 comments on commit 028998a

Please sign in to comment.