Fixed up test_db_api

This commit is contained in:
2024-01-13 19:02:55 +01:00
parent e7ec0a593c
commit a51e94fef3
21 changed files with 309 additions and 377 deletions

View File

@@ -1,3 +0,0 @@
#!/usr/bin/env bash
while true ; do printf 'HTTP/1.1 200 OK\r\n\r\ncool, thanks' | nc -l -N 127.0.0.1 7002; done

View File

@@ -20,7 +20,6 @@ __version__ = "1.0.0"
from openapi_client.api.default_api import DefaultApi
from openapi_client.api.entities_api import EntitiesApi
from openapi_client.api.eventmessages_api import EventmessagesApi
from openapi_client.api.repositories_api import RepositoriesApi
from openapi_client.api.resolution_api import ResolutionApi
from openapi_client.api.services_api import ServicesApi
@@ -43,7 +42,7 @@ from openapi_client.models.eventmessage_create import EventmessageCreate
from openapi_client.models.http_validation_error import HTTPValidationError
from openapi_client.models.machine import Machine
from openapi_client.models.resolution import Resolution
from openapi_client.models.roles import Roles
from openapi_client.models.role import Role
from openapi_client.models.service import Service
from openapi_client.models.service_create import ServiceCreate
from openapi_client.models.status import Status

View File

@@ -4,7 +4,6 @@
from openapi_client.api.default_api import DefaultApi
from openapi_client.api.entities_api import EntitiesApi
from openapi_client.api.eventmessages_api import EventmessagesApi
from openapi_client.api.repositories_api import RepositoriesApi
from openapi_client.api.resolution_api import ResolutionApi
from openapi_client.api.services_api import ServicesApi

View File

@@ -18,12 +18,13 @@ import warnings
from pydantic import validate_arguments, ValidationError
from pydantic import StrictInt, StrictStr
from pydantic import StrictInt, StrictStr, conlist
from typing import Any, List, Optional, Dict
from openapi_client.models.entity import Entity
from openapi_client.models.entity_create import EntityCreate
from openapi_client.models.role import Role
from openapi_client.api_client import ApiClient
from openapi_client.api_response import ApiResponse
@@ -184,7 +185,7 @@ class EntitiesApi:
}
return self.api_client.call_api(
'/api/v1/attach', 'POST',
'/api/v1/attach', 'PUT',
_path_params,
_query_params,
_header_params,
@@ -624,7 +625,7 @@ class EntitiesApi:
}
return self.api_client.call_api(
'/api/v1/detach', 'POST',
'/api/v1/detach', 'PUT',
_path_params,
_query_params,
_header_params,
@@ -1074,17 +1075,17 @@ class EntitiesApi:
_request_auth=_params.get('_request_auth'))
@validate_arguments
def get_entity_by_name(self, entity_name : StrictStr, **kwargs) -> Entity: # noqa: E501
"""Get Entity By Name # noqa: E501
def get_entity_by_name_or_did(self, entity_name_or_did : Optional[StrictStr] = None, **kwargs) -> Entity: # noqa: E501
"""Get Entity By Name Or Did # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.get_entity_by_name(entity_name, async_req=True)
>>> thread = api.get_entity_by_name_or_did(entity_name_or_did, async_req=True)
>>> result = thread.get()
:param entity_name: (required)
:type entity_name: str
:param entity_name_or_did:
:type entity_name_or_did: str
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _request_timeout: timeout setting for this request.
@@ -1098,22 +1099,22 @@ class EntitiesApi:
"""
kwargs['_return_http_data_only'] = True
if '_preload_content' in kwargs:
message = "Error! Please call the get_entity_by_name_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
message = "Error! Please call the get_entity_by_name_or_did_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
raise ValueError(message)
return self.get_entity_by_name_with_http_info(entity_name, **kwargs) # noqa: E501
return self.get_entity_by_name_or_did_with_http_info(entity_name_or_did, **kwargs) # noqa: E501
@validate_arguments
def get_entity_by_name_with_http_info(self, entity_name : StrictStr, **kwargs) -> ApiResponse: # noqa: E501
"""Get Entity By Name # noqa: E501
def get_entity_by_name_or_did_with_http_info(self, entity_name_or_did : Optional[StrictStr] = None, **kwargs) -> ApiResponse: # noqa: E501
"""Get Entity By Name Or Did # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.get_entity_by_name_with_http_info(entity_name, async_req=True)
>>> thread = api.get_entity_by_name_or_did_with_http_info(entity_name_or_did, async_req=True)
>>> result = thread.get()
:param entity_name: (required)
:type entity_name: str
:param entity_name_or_did:
:type entity_name_or_did: str
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _preload_content: if False, the ApiResponse.data will
@@ -1142,7 +1143,7 @@ class EntitiesApi:
_params = locals()
_all_params = [
'entity_name'
'entity_name_or_did'
]
_all_params.extend(
[
@@ -1161,7 +1162,7 @@ class EntitiesApi:
if _key not in _all_params:
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method get_entity_by_name" % _key
" to method get_entity_by_name_or_did" % _key
)
_params[_key] = _val
del _params['kwargs']
@@ -1173,8 +1174,8 @@ class EntitiesApi:
# process the query parameters
_query_params = []
if _params.get('entity_name') is not None: # noqa: E501
_query_params.append(('entity_name', _params['entity_name']))
if _params.get('entity_name_or_did') is not None: # noqa: E501
_query_params.append(('entity_name_or_did', _params['entity_name_or_did']))
# process the header parameters
_header_params = dict(_params.get('_headers', {}))
@@ -1196,7 +1197,147 @@ class EntitiesApi:
}
return self.api_client.call_api(
'/api/v1/entity_by_name', 'GET',
'/api/v1/entity_by_name_or_did', 'GET',
_path_params,
_query_params,
_header_params,
body=_body_params,
post_params=_form_params,
files=_files,
response_types_map=_response_types_map,
auth_settings=_auth_settings,
async_req=_params.get('async_req'),
_return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501
_preload_content=_params.get('_preload_content', True),
_request_timeout=_params.get('_request_timeout'),
collection_formats=_collection_formats,
_request_auth=_params.get('_request_auth'))
@validate_arguments
def get_entity_by_roles(self, roles : conlist(Role), **kwargs) -> List[Entity]: # noqa: E501
"""Get Entity By Roles # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.get_entity_by_roles(roles, async_req=True)
>>> result = thread.get()
:param roles: (required)
:type roles: List[Role]
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _request_timeout: timeout setting for this request.
If one number provided, it will be total request
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:return: Returns the result object.
If the method is called asynchronously,
returns the request thread.
:rtype: List[Entity]
"""
kwargs['_return_http_data_only'] = True
if '_preload_content' in kwargs:
message = "Error! Please call the get_entity_by_roles_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
raise ValueError(message)
return self.get_entity_by_roles_with_http_info(roles, **kwargs) # noqa: E501
@validate_arguments
def get_entity_by_roles_with_http_info(self, roles : conlist(Role), **kwargs) -> ApiResponse: # noqa: E501
"""Get Entity By Roles # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.get_entity_by_roles_with_http_info(roles, async_req=True)
>>> result = thread.get()
:param roles: (required)
:type roles: List[Role]
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _preload_content: if False, the ApiResponse.data will
be set to none and raw_data will store the
HTTP response body without reading/decoding.
Default is True.
:type _preload_content: bool, optional
:param _return_http_data_only: response data instead of ApiResponse
object with status code, headers, etc
:type _return_http_data_only: bool, optional
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:param _request_auth: set to override the auth_settings for an a single
request; this effectively ignores the authentication
in the spec for a single request.
:type _request_auth: dict, optional
:type _content_type: string, optional: force content-type for the request
:return: Returns the result object.
If the method is called asynchronously,
returns the request thread.
:rtype: tuple(List[Entity], status_code(int), headers(HTTPHeaderDict))
"""
_params = locals()
_all_params = [
'roles'
]
_all_params.extend(
[
'async_req',
'_return_http_data_only',
'_preload_content',
'_request_timeout',
'_request_auth',
'_content_type',
'_headers'
]
)
# validate the arguments
for _key, _val in _params['kwargs'].items():
if _key not in _all_params:
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method get_entity_by_roles" % _key
)
_params[_key] = _val
del _params['kwargs']
_collection_formats = {}
# process the path parameters
_path_params = {}
# process the query parameters
_query_params = []
if _params.get('roles') is not None: # noqa: E501
_query_params.append(('roles', _params['roles']))
_collection_formats['roles'] = 'multi'
# process the header parameters
_header_params = dict(_params.get('_headers', {}))
# process the form parameters
_form_params = []
_files = {}
# process the body parameter
_body_params = None
# set the HTTP header `Accept`
_header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501
# authentication setting
_auth_settings = [] # noqa: E501
_response_types_map = {
'200': "List[Entity]",
'422': "HTTPValidationError",
}
return self.api_client.call_api(
'/api/v1/entity_by_roles', 'GET',
_path_params,
_query_params,
_header_params,

View File

@@ -175,7 +175,7 @@ class EventmessagesApi:
}
return self.api_client.call_api(
'/api/v1/send_msg', 'POST',
'/api/v1/event_message', 'POST',
_path_params,
_query_params,
_header_params,

View File

@@ -1,192 +0,0 @@
# coding: utf-8
"""
FastAPI
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: 0.1.0
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
""" # noqa: E501
import re # noqa: F401
import io
import warnings
from pydantic import validate_arguments, ValidationError
from pydantic import StrictInt
from typing import List, Optional
from openapi_client.models.service import Service
from openapi_client.api_client import ApiClient
from openapi_client.api_response import ApiResponse
from openapi_client.exceptions import ( # noqa: F401
ApiTypeError,
ApiValueError
)
class RepositoriesApi:
"""NOTE: This class is auto generated by OpenAPI Generator
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
def __init__(self, api_client=None) -> None:
if api_client is None:
api_client = ApiClient.get_default()
self.api_client = api_client
@validate_arguments
def get_all_repositories(self, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> List[Service]: # noqa: E501
"""Get All Repositories # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.get_all_repositories(skip, limit, async_req=True)
>>> result = thread.get()
:param skip:
:type skip: int
:param limit:
:type limit: int
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _request_timeout: timeout setting for this request.
If one number provided, it will be total request
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:return: Returns the result object.
If the method is called asynchronously,
returns the request thread.
:rtype: List[Service]
"""
kwargs['_return_http_data_only'] = True
if '_preload_content' in kwargs:
message = "Error! Please call the get_all_repositories_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
raise ValueError(message)
return self.get_all_repositories_with_http_info(skip, limit, **kwargs) # noqa: E501
@validate_arguments
def get_all_repositories_with_http_info(self, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> ApiResponse: # noqa: E501
"""Get All Repositories # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.get_all_repositories_with_http_info(skip, limit, async_req=True)
>>> result = thread.get()
:param skip:
:type skip: int
:param limit:
:type limit: int
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _preload_content: if False, the ApiResponse.data will
be set to none and raw_data will store the
HTTP response body without reading/decoding.
Default is True.
:type _preload_content: bool, optional
:param _return_http_data_only: response data instead of ApiResponse
object with status code, headers, etc
:type _return_http_data_only: bool, optional
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:param _request_auth: set to override the auth_settings for an a single
request; this effectively ignores the authentication
in the spec for a single request.
:type _request_auth: dict, optional
:type _content_type: string, optional: force content-type for the request
:return: Returns the result object.
If the method is called asynchronously,
returns the request thread.
:rtype: tuple(List[Service], status_code(int), headers(HTTPHeaderDict))
"""
_params = locals()
_all_params = [
'skip',
'limit'
]
_all_params.extend(
[
'async_req',
'_return_http_data_only',
'_preload_content',
'_request_timeout',
'_request_auth',
'_content_type',
'_headers'
]
)
# validate the arguments
for _key, _val in _params['kwargs'].items():
if _key not in _all_params:
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method get_all_repositories" % _key
)
_params[_key] = _val
del _params['kwargs']
_collection_formats = {}
# process the path parameters
_path_params = {}
# process the query parameters
_query_params = []
if _params.get('skip') is not None: # noqa: E501
_query_params.append(('skip', _params['skip']))
if _params.get('limit') is not None: # noqa: E501
_query_params.append(('limit', _params['limit']))
# process the header parameters
_header_params = dict(_params.get('_headers', {}))
# process the form parameters
_form_params = []
_files = {}
# process the body parameter
_body_params = None
# set the HTTP header `Accept`
_header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501
# authentication setting
_auth_settings = [] # noqa: E501
_response_types_map = {
'200': "List[Service]",
'422': "HTTPValidationError",
}
return self.api_client.call_api(
'/api/v1/repositories', 'GET',
_path_params,
_query_params,
_header_params,
body=_body_params,
post_params=_form_params,
files=_files,
response_types_map=_response_types_map,
auth_settings=_auth_settings,
async_req=_params.get('async_req'),
_return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501
_preload_content=_params.get('_preload_content', True),
_request_timeout=_params.get('_request_timeout'),
collection_formats=_collection_formats,
_request_auth=_params.get('_request_auth'))

View File

@@ -2,17 +2,18 @@
All URIs are relative to _http://localhost_
| Method | HTTP request | Description |
| ----------------------------------------------------------------- | --------------------------------- | --------------------- |
| [**attach_entity**](EntitiesApi.md#attach_entity) | **POST** /api/v1/attach | Attach Entity |
| [**create_entity**](EntitiesApi.md#create_entity) | **POST** /api/v1/entity | Create Entity |
| [**delete_entity**](EntitiesApi.md#delete_entity) | **DELETE** /api/v1/entity | Delete Entity |
| [**detach_entity**](EntitiesApi.md#detach_entity) | **POST** /api/v1/detach | Detach Entity |
| [**get_all_entities**](EntitiesApi.md#get_all_entities) | **GET** /api/v1/entities | Get All Entities |
| [**get_attached_entities**](EntitiesApi.md#get_attached_entities) | **GET** /api/v1/attached_entities | Get Attached Entities |
| [**get_entity_by_did**](EntitiesApi.md#get_entity_by_did) | **GET** /api/v1/entity | Get Entity By Did |
| [**get_entity_by_name**](EntitiesApi.md#get_entity_by_name) | **GET** /api/v1/entity_by_name | Get Entity By Name |
| [**is_attached**](EntitiesApi.md#is_attached) | **GET** /api/v1/is_attached | Is Attached |
| Method | HTTP request | Description |
| ------------------------------------------------------------------------- | ------------------------------------- | ------------------------- |
| [**attach_entity**](EntitiesApi.md#attach_entity) | **PUT** /api/v1/attach | Attach Entity |
| [**create_entity**](EntitiesApi.md#create_entity) | **POST** /api/v1/entity | Create Entity |
| [**delete_entity**](EntitiesApi.md#delete_entity) | **DELETE** /api/v1/entity | Delete Entity |
| [**detach_entity**](EntitiesApi.md#detach_entity) | **PUT** /api/v1/detach | Detach Entity |
| [**get_all_entities**](EntitiesApi.md#get_all_entities) | **GET** /api/v1/entities | Get All Entities |
| [**get_attached_entities**](EntitiesApi.md#get_attached_entities) | **GET** /api/v1/attached_entities | Get Attached Entities |
| [**get_entity_by_did**](EntitiesApi.md#get_entity_by_did) | **GET** /api/v1/entity | Get Entity By Did |
| [**get_entity_by_name_or_did**](EntitiesApi.md#get_entity_by_name_or_did) | **GET** /api/v1/entity_by_name_or_did | Get Entity By Name Or Did |
| [**get_entity_by_roles**](EntitiesApi.md#get_entity_by_roles) | **GET** /api/v1/entity_by_roles | Get Entity By Roles |
| [**is_attached**](EntitiesApi.md#is_attached) | **GET** /api/v1/is_attached | Is Attached |
# **attach_entity**
@@ -486,11 +487,11 @@ No authorization required
[[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)
# **get_entity_by_name**
# **get_entity_by_name_or_did**
> Entity get_entity_by_name(entity_name)
> Entity get_entity_by_name_or_did(entity_name_or_did=entity_name_or_did)
Get Entity By Name
Get Entity By Name Or Did
### Example
@@ -513,22 +514,22 @@ configuration = openapi_client.Configuration(
with openapi_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = openapi_client.EntitiesApi(api_client)
entity_name = 'entity_name_example' # str |
entity_name_or_did = 'C1' # str | (optional) (default to 'C1')
try:
# Get Entity By Name
api_response = api_instance.get_entity_by_name(entity_name)
print("The response of EntitiesApi->get_entity_by_name:\n")
# Get Entity By Name Or Did
api_response = api_instance.get_entity_by_name_or_did(entity_name_or_did=entity_name_or_did)
print("The response of EntitiesApi->get_entity_by_name_or_did:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling EntitiesApi->get_entity_by_name: %s\n" % e)
print("Exception when calling EntitiesApi->get_entity_by_name_or_did: %s\n" % e)
```
### Parameters
| Name | Type | Description | Notes |
| --------------- | ------- | ----------- | ----- |
| **entity_name** | **str** | |
| Name | Type | Description | Notes |
| ---------------------- | ------- | ----------- | ------------------------------------ |
| **entity_name_or_did** | **str** | | [optional] [default to 'C1'] |
### Return type
@@ -552,6 +553,73 @@ No authorization required
[[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)
# **get_entity_by_roles**
> List[Entity] get_entity_by_roles(roles)
Get Entity By Roles
### Example
```python
import time
import os
import openapi_client
from openapi_client.models.entity import Entity
from openapi_client.models.role import Role
from openapi_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to http://localhost
# See configuration.py for a list of all supported configuration parameters.
configuration = openapi_client.Configuration(
host = "http://localhost"
)
# Enter a context with an instance of the API client
with openapi_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = openapi_client.EntitiesApi(api_client)
roles = [openapi_client.Role()] # List[Role] |
try:
# Get Entity By Roles
api_response = api_instance.get_entity_by_roles(roles)
print("The response of EntitiesApi->get_entity_by_roles:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling EntitiesApi->get_entity_by_roles: %s\n" % e)
```
### Parameters
| Name | Type | Description | Notes |
| --------- | ------------------------- | ----------- | ----- |
| **roles** | [**List[Role]**](Role.md) | |
### Return type
[**List[Entity]**](Entity.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
### HTTP response details
| Status code | Description | Response headers |
| ----------- | ------------------- | ---------------- |
| **200** | Successful Response | - |
| **422** | Validation 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)
# **is_attached**
> Dict[str, str] is_attached(entity_did=entity_did)

View File

@@ -2,17 +2,17 @@
## Properties
| Name | Type | Description | Notes |
| -------------------- | --------------------- | ----------- | ----- |
| **did** | **str** | |
| **name** | **str** | |
| **ip** | **str** | |
| **network** | **str** | |
| **role** | [**Roles**](Roles.md) | |
| **visible** | **bool** | |
| **other** | **object** | |
| **attached** | **bool** | |
| **stop_health_task** | **bool** | |
| Name | Type | Description | Notes |
| -------------------- | ------------------------- | ----------- | ----- |
| **did** | **str** | |
| **name** | **str** | |
| **ip** | **str** | |
| **network** | **str** | |
| **visible** | **bool** | |
| **other** | **object** | |
| **attached** | **bool** | |
| **stop_health_task** | **bool** | |
| **roles** | [**List[Role]**](Role.md) | |
## Example

View File

@@ -2,15 +2,15 @@
## Properties
| Name | Type | Description | Notes |
| ----------- | --------------------- | ----------- | ----- |
| **did** | **str** | |
| **name** | **str** | |
| **ip** | **str** | |
| **network** | **str** | |
| **role** | [**Roles**](Roles.md) | |
| **visible** | **bool** | |
| **other** | **object** | |
| Name | Type | Description | Notes |
| ----------- | ------------------------- | ----------- | ----- |
| **did** | **str** | |
| **name** | **str** | |
| **ip** | **str** | |
| **network** | **str** | |
| **visible** | **bool** | |
| **other** | **object** | |
| **roles** | [**List[Role]**](Role.md) | |
## Example

View File

@@ -4,7 +4,6 @@
| Name | Type | Description | Notes |
| ------------- | ---------- | ----------- | ----- |
| **id** | **int** | |
| **timestamp** | **int** | |
| **group** | **int** | |
| **group_id** | **int** | |
@@ -12,6 +11,7 @@
| **src_did** | **str** | |
| **des_did** | **str** | |
| **msg** | **object** | |
| **id** | **int** | |
## Example

View File

@@ -4,7 +4,6 @@
| Name | Type | Description | Notes |
| ------------- | ---------- | ----------- | ----- |
| **id** | **int** | |
| **timestamp** | **int** | |
| **group** | **int** | |
| **group_id** | **int** | |

View File

@@ -4,7 +4,7 @@ All URIs are relative to _http://localhost_
| Method | HTTP request | Description |
| ---------------------------------------------------------------------- | ------------------------------ | --------------------- |
| [**create_eventmessage**](EventmessagesApi.md#create_eventmessage) | **POST** /api/v1/send_msg | Create Eventmessage |
| [**create_eventmessage**](EventmessagesApi.md#create_eventmessage) | **POST** /api/v1/event_message | Create Eventmessage |
| [**get_all_eventmessages**](EventmessagesApi.md#get_all_eventmessages) | **GET** /api/v1/event_messages | Get All Eventmessages |
# **create_eventmessage**

View File

@@ -1,75 +0,0 @@
# openapi_client.RepositoriesApi
All URIs are relative to _http://localhost_
| Method | HTTP request | Description |
| ------------------------------------------------------------------- | ---------------------------- | -------------------- |
| [**get_all_repositories**](RepositoriesApi.md#get_all_repositories) | **GET** /api/v1/repositories | Get All Repositories |
# **get_all_repositories**
> List[Service] get_all_repositories(skip=skip, limit=limit)
Get All Repositories
### Example
```python
import time
import os
import openapi_client
from openapi_client.models.service import Service
from openapi_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to http://localhost
# See configuration.py for a list of all supported configuration parameters.
configuration = openapi_client.Configuration(
host = "http://localhost"
)
# Enter a context with an instance of the API client
with openapi_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = openapi_client.RepositoriesApi(api_client)
skip = 0 # int | (optional) (default to 0)
limit = 100 # int | (optional) (default to 100)
try:
# Get All Repositories
api_response = api_instance.get_all_repositories(skip=skip, limit=limit)
print("The response of RepositoriesApi->get_all_repositories:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling RepositoriesApi->get_all_repositories: %s\n" % e)
```
### Parameters
| Name | Type | Description | Notes |
| --------- | ------- | ----------- | --------------------------- |
| **skip** | **int** | | [optional] [default to 0] |
| **limit** | **int** | | [optional] [default to 100] |
### Return type
[**List[Service]**](Service.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
### HTTP response details
| Status code | Description | Response headers |
| ----------- | ------------------- | ---------------- |
| **200** | Successful Response | - |
| **422** | Validation 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)

View File

@@ -21,7 +21,7 @@ from openapi_client.models.eventmessage_create import EventmessageCreate
from openapi_client.models.http_validation_error import HTTPValidationError
from openapi_client.models.machine import Machine
from openapi_client.models.resolution import Resolution
from openapi_client.models.roles import Roles
from openapi_client.models.role import Role
from openapi_client.models.service import Service
from openapi_client.models.service_create import ServiceCreate
from openapi_client.models.status import Status

View File

@@ -18,9 +18,9 @@ import re # noqa: F401
import json
from typing import Any, Dict
from pydantic import BaseModel, Field, StrictBool, StrictStr
from openapi_client.models.roles import Roles
from typing import Any, Dict, List
from pydantic import BaseModel, Field, StrictBool, StrictStr, conlist
from openapi_client.models.role import Role
class Entity(BaseModel):
"""
@@ -30,12 +30,12 @@ class Entity(BaseModel):
name: StrictStr = Field(...)
ip: StrictStr = Field(...)
network: StrictStr = Field(...)
role: Roles = Field(...)
visible: StrictBool = Field(...)
other: Dict[str, Any] = Field(...)
attached: StrictBool = Field(...)
stop_health_task: StrictBool = Field(...)
__properties = ["did", "name", "ip", "network", "role", "visible", "other", "attached", "stop_health_task"]
roles: conlist(Role) = Field(...)
__properties = ["did", "name", "ip", "network", "visible", "other", "attached", "stop_health_task", "roles"]
class Config:
"""Pydantic configuration"""
@@ -77,11 +77,11 @@ class Entity(BaseModel):
"name": obj.get("name"),
"ip": obj.get("ip"),
"network": obj.get("network"),
"role": obj.get("role"),
"visible": obj.get("visible"),
"other": obj.get("other"),
"attached": obj.get("attached"),
"stop_health_task": obj.get("stop_health_task")
"stop_health_task": obj.get("stop_health_task"),
"roles": obj.get("roles")
})
return _obj

View File

@@ -18,9 +18,9 @@ import re # noqa: F401
import json
from typing import Any, Dict
from pydantic import BaseModel, Field, StrictBool, StrictStr
from openapi_client.models.roles import Roles
from typing import Any, Dict, List
from pydantic import BaseModel, Field, StrictBool, StrictStr, conlist
from openapi_client.models.role import Role
class EntityCreate(BaseModel):
"""
@@ -30,10 +30,10 @@ class EntityCreate(BaseModel):
name: StrictStr = Field(...)
ip: StrictStr = Field(...)
network: StrictStr = Field(...)
role: Roles = Field(...)
visible: StrictBool = Field(...)
other: Dict[str, Any] = Field(...)
__properties = ["did", "name", "ip", "network", "role", "visible", "other"]
roles: conlist(Role) = Field(...)
__properties = ["did", "name", "ip", "network", "visible", "other", "roles"]
class Config:
"""Pydantic configuration"""
@@ -75,9 +75,9 @@ class EntityCreate(BaseModel):
"name": obj.get("name"),
"ip": obj.get("ip"),
"network": obj.get("network"),
"role": obj.get("role"),
"visible": obj.get("visible"),
"other": obj.get("other")
"other": obj.get("other"),
"roles": obj.get("roles")
})
return _obj

View File

@@ -25,7 +25,6 @@ class Eventmessage(BaseModel):
"""
Eventmessage
"""
id: StrictInt = Field(...)
timestamp: StrictInt = Field(...)
group: StrictInt = Field(...)
group_id: StrictInt = Field(...)
@@ -33,7 +32,8 @@ class Eventmessage(BaseModel):
src_did: StrictStr = Field(...)
des_did: StrictStr = Field(...)
msg: Dict[str, Any] = Field(...)
__properties = ["id", "timestamp", "group", "group_id", "msg_type", "src_did", "des_did", "msg"]
id: StrictInt = Field(...)
__properties = ["timestamp", "group", "group_id", "msg_type", "src_did", "des_did", "msg", "id"]
class Config:
"""Pydantic configuration"""
@@ -71,14 +71,14 @@ class Eventmessage(BaseModel):
return Eventmessage.parse_obj(obj)
_obj = Eventmessage.parse_obj({
"id": obj.get("id"),
"timestamp": obj.get("timestamp"),
"group": obj.get("group"),
"group_id": obj.get("group_id"),
"msg_type": obj.get("msg_type"),
"src_did": obj.get("src_did"),
"des_did": obj.get("des_did"),
"msg": obj.get("msg")
"msg": obj.get("msg"),
"id": obj.get("id")
})
return _obj

View File

@@ -25,7 +25,6 @@ class EventmessageCreate(BaseModel):
"""
EventmessageCreate
"""
id: StrictInt = Field(...)
timestamp: StrictInt = Field(...)
group: StrictInt = Field(...)
group_id: StrictInt = Field(...)
@@ -33,7 +32,7 @@ class EventmessageCreate(BaseModel):
src_did: StrictStr = Field(...)
des_did: StrictStr = Field(...)
msg: Dict[str, Any] = Field(...)
__properties = ["id", "timestamp", "group", "group_id", "msg_type", "src_did", "des_did", "msg"]
__properties = ["timestamp", "group", "group_id", "msg_type", "src_did", "des_did", "msg"]
class Config:
"""Pydantic configuration"""
@@ -71,7 +70,6 @@ class EventmessageCreate(BaseModel):
return EventmessageCreate.parse_obj(obj)
_obj = EventmessageCreate.parse_obj({
"id": obj.get("id"),
"timestamp": obj.get("timestamp"),
"group": obj.get("group"),
"group_id": obj.get("group_id"),

View File

@@ -21,7 +21,7 @@ from aenum import Enum, no_arg
class Roles(str, Enum):
class Role(str, Enum):
"""
An enumeration.
"""
@@ -34,8 +34,8 @@ class Roles(str, Enum):
DLG = 'DLG'
@classmethod
def from_json(cls, json_str: str) -> Roles:
"""Create an instance of Roles from a JSON string"""
return Roles(json.loads(json_str))
def from_json(cls, json_str: str) -> Role:
"""Create an instance of Role from a JSON string"""
return Role(json.loads(json_str))

View File

@@ -13,7 +13,7 @@ from openapi_client.models import (
Eventmessage,
EventmessageCreate,
Machine,
Roles,
Role,
ServiceCreate,
Status,
)
@@ -46,7 +46,7 @@ def create_entities(num: int = 10, role: str = "entity") -> list[EntityCreate]:
name=f"C{i}",
ip=f"{host}:{port_client_base+i}",
network="255.255.0.0",
role=Roles("service_prosumer"),
roles=[Role("service_prosumer")],
visible=True,
other={},
)
@@ -56,7 +56,7 @@ def create_entities(num: int = 10, role: str = "entity") -> list[EntityCreate]:
name="DLG",
ip=f"{host}:{port_dlg}/health",
network="255.255.0.0",
role=Roles("DLG"),
roles=[Role("DLG")],
visible=True,
other={},
)
@@ -66,7 +66,7 @@ def create_entities(num: int = 10, role: str = "entity") -> list[EntityCreate]:
name="AP",
ip=f"{host}:{port_ap}/health",
network="255.255.0.0",
role=Roles("AP"),
roles=[Role("AP")],
visible=True,
other={},
)
@@ -116,7 +116,6 @@ def create_eventmessages(num: int = 2) -> list[EventmessageCreate]:
for i in range(num):
group_id = i % 5 + random.getrandbits(6)
em_req_send = EventmessageCreate(
id=random.getrandbits(18),
timestamp=starttime + i * 10,
group=i % 5,
group_id=group_id,
@@ -127,7 +126,6 @@ def create_eventmessages(num: int = 2) -> list[EventmessageCreate]:
)
res.append(em_req_send)
em_req_rec = EventmessageCreate(
id=random.getrandbits(18),
timestamp=starttime + (i * 10) + 2,
group=i % 5,
group_id=group_id,
@@ -139,7 +137,6 @@ def create_eventmessages(num: int = 2) -> list[EventmessageCreate]:
res.append(em_req_rec)
group_id = i % 5 + random.getrandbits(6)
em_res_send = EventmessageCreate(
id=random.getrandbits(18),
timestamp=starttime + i * 10 + 4,
group=i % 5,
group_id=group_id,
@@ -150,7 +147,6 @@ def create_eventmessages(num: int = 2) -> list[EventmessageCreate]:
)
res.append(em_res_send)
em_res_rec = EventmessageCreate(
id=random.getrandbits(6),
timestamp=starttime + (i * 10) + 8,
group=i % 5,
group_id=group_id,
@@ -166,8 +162,10 @@ def create_eventmessages(num: int = 2) -> list[EventmessageCreate]:
def test_create_eventmessages(api_client: ApiClient) -> None:
api = EventmessagesApi(api_client=api_client)
assert [] == api.get_all_eventmessages()
for own_eventmsg in create_eventmessages():
for idx, own_eventmsg in enumerate(create_eventmessages()):
res: Eventmessage = api.create_eventmessage(own_eventmsg)
# breakpoint()
assert res.id == own_eventmsg.id
assert res.msg == own_eventmsg.msg
assert res.src_did == own_eventmsg.src_did
assert res.des_did == own_eventmsg.des_did
assert [] != api.get_all_eventmessages()