Skip to content

Commit

Permalink
Merge pull request #4 from blues/feat-openapi-update
Browse files Browse the repository at this point in the history
feat: Add Alerts API to package
  • Loading branch information
paigen11 authored May 15, 2024
2 parents c19d7ab + ed9cd4a commit e02866a
Show file tree
Hide file tree
Showing 26 changed files with 1,482 additions and 8 deletions.
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"packageName": "notehub_py",
"packageUrl": "https://github.com/blues/notehub-py",
"projectName": "notehub-py",
"packageVersion": "0.0.2"
"packageVersion": "0.0.3"
}
110 changes: 109 additions & 1 deletion openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1975,6 +1975,24 @@ paths:
$ref: "#/components/schemas/Monitor"
default:
$ref: "#/components/responses/ErrorResponse"

/v1/projects/{projectUID}/alerts:
get:
tags: [ "alert" ]
operationId: getAlerts
description: Get list of defined Alerts
security:
- api_key: []
parameters:
- $ref: "#/components/parameters/projectUIDParam"
- $ref: "#/components/parameters/pageSizeParam"
- $ref: "#/components/parameters/pageNumParam"
responses:
"200":
$ref: "#/components/responses/AlertsResponse"
default:
$ref: "#/components/responses/ErrorResponse"

/v1/projects/{projectUID}/firmware:
get:
tags: [ "firmware" ]
Expand Down Expand Up @@ -2634,6 +2652,25 @@ components:
required:
- monitors

AlertsResponse:
description: The response body from GET /alerts
content:
application/json:
schema:
type: object
properties:
alerts:
type: array
items:
$ref: "#/components/schemas/Alert"
description: The list of alerts
has_more:
type: boolean
description: True if there are more alerts
required:
- alerts
- has_more

schemas:
Error:
type: object
Expand Down Expand Up @@ -4095,7 +4132,6 @@ components:
- notefile_filter
- alert_routes


Empty:
type: object

Expand Down Expand Up @@ -4138,3 +4174,75 @@ components:
published:
type: boolean
description: True if the firmware is published.

Alert:
type: object
properties:
uid:
type: string
description: Alert UID
monitor_uid:
type: string
description: Monitor UID
device_uid:
type: string
description: Device UID
created_at:
type: integer
description: The time the alert was created
value:
type: number
description: The value that triggered the alert
resolved:
type: boolean
description: If true, the alert has been resolved
version:
type: integer
description: The version of the alert
alert_source:
type: string
enum: [app, device]
description: The source of the alert
source:
type: string
description: The UID of the source of the alert
data:
type: array
items:
type: object
properties:
alert_source:
type: string
enum: [app, device]
description: The source of the alert
source:
type: string
description: The UID of the source of the alert
source_type:
type: string
enum: [event]
description: The type of source.
value:
type: number
description: The value that triggered the alert
source_uid:
type: string
description: The UID of the source of the alert
when:
type: string
description: The time the alert was created
notifications:
type: array
items:
type: object
properties:
notification_type:
type: string
enum: [email, slack]
description: The type of notification
status:
type: number
description: The status of the notification
recipients:
type: string
description: The recipients of the notification
10 changes: 10 additions & 0 deletions src/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
.gitlab-ci.yml
.travis.yml
README.md
docs/Alert.md
docs/AlertApi.md
docs/AlertDataInner.md
docs/AlertNotificationsInner.md
docs/AuthorizationApi.md
docs/Aws.md
docs/Azure.md
Expand Down Expand Up @@ -31,6 +35,7 @@ docs/EventApi.md
docs/FirmwareApi.md
docs/FirmwareInfo.md
docs/Fleet.md
docs/GetAlerts200Response.md
docs/GetBillingAccounts200Response.md
docs/GetDeviceEnvironmentVariables200Response.md
docs/GetDeviceHealthLog200Response.md
Expand Down Expand Up @@ -90,6 +95,7 @@ docs/UserDbRoute.md
git_push.sh
notehub_py/__init__.py
notehub_py/api/__init__.py
notehub_py/api/alert_api.py
notehub_py/api/authorization_api.py
notehub_py/api/billing_account_api.py
notehub_py/api/device_api.py
Expand All @@ -103,6 +109,9 @@ notehub_py/api_response.py
notehub_py/configuration.py
notehub_py/exceptions.py
notehub_py/models/__init__.py
notehub_py/models/alert.py
notehub_py/models/alert_data_inner.py
notehub_py/models/alert_notifications_inner.py
notehub_py/models/aws.py
notehub_py/models/azure.py
notehub_py/models/billing_account.py
Expand All @@ -126,6 +135,7 @@ notehub_py/models/error.py
notehub_py/models/event.py
notehub_py/models/firmware_info.py
notehub_py/models/fleet.py
notehub_py/models/get_alerts200_response.py
notehub_py/models/get_billing_accounts200_response.py
notehub_py/models/get_device_environment_variables200_response.py
notehub_py/models/get_device_health_log200_response.py
Expand Down
7 changes: 6 additions & 1 deletion src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The OpenAPI definition for the Notehub.io API.
This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:

- API version: 1.0.0
- Package version: 0.0.2
- Package version: 0.0.3
- Generator version: 7.5.0
- Build package: org.openapitools.codegen.languages.PythonClientCodegen
For more information, please visit [https://dev.blues.io/support/](https://dev.blues.io/support/)
Expand Down Expand Up @@ -93,6 +93,7 @@ All URIs are relative to *https://api.notefile.net*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*AlertApi* | [**get_alerts**](docs/AlertApi.md#get_alerts) | **GET** /v1/projects/{projectUID}/alerts |
*AuthorizationApi* | [**login**](docs/AuthorizationApi.md#login) | **POST** /auth/login |
*BillingAccountApi* | [**get_billing_accounts**](docs/BillingAccountApi.md#get_billing_accounts) | **GET** /v1/billing-accounts |
*DeviceApi* | [**delete_device_environment_variable**](docs/DeviceApi.md#delete_device_environment_variable) | **DELETE** /v1/projects/{projectUID}/devices/{deviceUID}/environment_variables/{key} |
Expand Down Expand Up @@ -170,6 +171,9 @@ Class | Method | HTTP request | Description

## Documentation For Models

- [Alert](docs/Alert.md)
- [AlertDataInner](docs/AlertDataInner.md)
- [AlertNotificationsInner](docs/AlertNotificationsInner.md)
- [Aws](docs/Aws.md)
- [Azure](docs/Azure.md)
- [BillingAccount](docs/BillingAccount.md)
Expand All @@ -193,6 +197,7 @@ Class | Method | HTTP request | Description
- [Event](docs/Event.md)
- [FirmwareInfo](docs/FirmwareInfo.md)
- [Fleet](docs/Fleet.md)
- [GetAlerts200Response](docs/GetAlerts200Response.md)
- [GetBillingAccounts200Response](docs/GetBillingAccounts200Response.md)
- [GetDeviceEnvironmentVariables200Response](docs/GetDeviceEnvironmentVariables200Response.md)
- [GetDeviceHealthLog200Response](docs/GetDeviceHealthLog200Response.md)
Expand Down
39 changes: 39 additions & 0 deletions src/docs/Alert.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Alert


## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**uid** | **str** | Alert UID | [optional]
**monitor_uid** | **str** | Monitor UID | [optional]
**device_uid** | **str** | Device UID | [optional]
**created_at** | **int** | The time the alert was created | [optional]
**value** | **float** | The value that triggered the alert | [optional]
**resolved** | **bool** | If true, the alert has been resolved | [optional]
**version** | **int** | The version of the alert | [optional]
**alert_source** | **str** | The source of the alert | [optional]
**source** | **str** | The UID of the source of the alert | [optional]
**data** | [**List[AlertDataInner]**](AlertDataInner.md) | | [optional]
**notifications** | [**List[AlertNotificationsInner]**](AlertNotificationsInner.md) | | [optional]

## Example

```python
from notehub_py.models.alert import Alert

# TODO update the JSON string below
json = "{}"
# create an instance of Alert from a JSON string
alert_instance = Alert.from_json(json)
# print the JSON string representation of the object
print(Alert.to_json())

# convert the object into a dict
alert_dict = alert_instance.to_dict()
# create an instance of Alert from a dict
alert_from_dict = Alert.from_dict(alert_dict)
```
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


92 changes: 92 additions & 0 deletions src/docs/AlertApi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# notehub_py.AlertApi

All URIs are relative to *https://api.notefile.net*

Method | HTTP request | Description
------------- | ------------- | -------------
[**get_alerts**](AlertApi.md#get_alerts) | **GET** /v1/projects/{projectUID}/alerts |


# **get_alerts**
> GetAlerts200Response get_alerts(project_uid, page_size=page_size, page_num=page_num)


Get list of defined Alerts

### Example

* Api Key Authentication (api_key):

```python
import notehub_py
from notehub_py.models.get_alerts200_response import GetAlerts200Response
from notehub_py.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://api.notefile.net
# See configuration.py for a list of all supported configuration parameters.
configuration = notehub_py.Configuration(
host = "https://api.notefile.net"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: api_key
configuration.api_key['api_key'] = os.environ["API_KEY"]

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['api_key'] = 'Bearer'

# Enter a context with an instance of the API client
with notehub_py.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = notehub_py.AlertApi(api_client)
project_uid = 'app:2606f411-dea6-44a0-9743-1130f57d77d8' # str |
page_size = 50 # int | (optional) (default to 50)
page_num = 1 # int | (optional) (default to 1)

try:
api_response = api_instance.get_alerts(project_uid, page_size=page_size, page_num=page_num)
print("The response of AlertApi->get_alerts:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling AlertApi->get_alerts: %s\n" % e)
```



### Parameters


Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**project_uid** | **str**| |
**page_size** | **int**| | [optional] [default to 50]
**page_num** | **int**| | [optional] [default to 1]

### Return type

[**GetAlerts200Response**](GetAlerts200Response.md)

### Authorization

[api_key](../README.md#api_key)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: application/json

### HTTP response details

| Status code | Description | Response headers |
|-------------|-------------|------------------|
**200** | The response body from GET /alerts | - |
**0** | The response body in case of an API error. | - |

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

34 changes: 34 additions & 0 deletions src/docs/AlertDataInner.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# AlertDataInner


## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**alert_source** | **str** | The source of the alert | [optional]
**source** | **str** | The UID of the source of the alert | [optional]
**source_type** | **str** | The type of source. | [optional]
**value** | **float** | The value that triggered the alert | [optional]
**source_uid** | **str** | The UID of the source of the alert | [optional]
**when** | **str** | The time the alert was created | [optional]

## Example

```python
from notehub_py.models.alert_data_inner import AlertDataInner

# TODO update the JSON string below
json = "{}"
# create an instance of AlertDataInner from a JSON string
alert_data_inner_instance = AlertDataInner.from_json(json)
# print the JSON string representation of the object
print(AlertDataInner.to_json())

# convert the object into a dict
alert_data_inner_dict = alert_data_inner_instance.to_dict()
# create an instance of AlertDataInner from a dict
alert_data_inner_from_dict = AlertDataInner.from_dict(alert_data_inner_dict)
```
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


Loading

0 comments on commit e02866a

Please sign in to comment.