From 65354221481fc599190c4db8acaea3f31c646f70 Mon Sep 17 00:00:00 2001 From: Luis-Hebendanz Date: Sun, 7 Jan 2024 14:02:23 +0100 Subject: [PATCH] Fixed mypy complaints --- pkgs/clan-cli/pyproject.toml | 7 +- .../clan-cli/tests/openapi_client/__init__.py | 2 +- .../tests/openapi_client/api/__init__.py | 1 - .../tests/openapi_client/api/clients_api.py | 200 ------------------ .../tests/openapi_client/api/services_api.py | 156 ++++++++++++++ .../tests/openapi_client/docs/ClientsApi.md | 77 ------- .../tests/openapi_client/docs/ServicesApi.md | 83 +++++++- .../openapi_client/docs/ServicesByName.md | 28 +++ .../tests/openapi_client/models/__init__.py | 1 + .../openapi_client/models/services_by_name.py | 85 ++++++++ .../openapi_client/test/test_clients_api.py | 38 ---- .../openapi_client/test/test_services_api.py | 7 + .../test/test_services_by_name.py | 99 +++++++++ pkgs/ui/src/app/client/[client_name]/page.tsx | 5 +- pkgs/ui/src/components/table/index.tsx | 20 +- 15 files changed, 473 insertions(+), 336 deletions(-) delete mode 100644 pkgs/clan-cli/tests/openapi_client/api/clients_api.py delete mode 100644 pkgs/clan-cli/tests/openapi_client/docs/ClientsApi.md create mode 100644 pkgs/clan-cli/tests/openapi_client/docs/ServicesByName.md create mode 100644 pkgs/clan-cli/tests/openapi_client/models/services_by_name.py delete mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_clients_api.py create mode 100644 pkgs/clan-cli/tests/openapi_client/test/test_services_by_name.py diff --git a/pkgs/clan-cli/pyproject.toml b/pkgs/clan-cli/pyproject.toml index 0149e3a..7fa8caf 100644 --- a/pkgs/clan-cli/pyproject.toml +++ b/pkgs/clan-cli/pyproject.toml @@ -31,12 +31,15 @@ warn_redundant_casts = true disallow_untyped_calls = true disallow_untyped_defs = true no_implicit_optional = true +follow_imports = "normal" exclude = [ "clan_cli.nixpkgs", - "tests/openapi_client", - "openapi_client", ] +[[tool.mypy.overrides]] +module = "openapi_client.*" +ignore_errors = true + [[tool.mypy.overrides]] module = "argcomplete.*" ignore_missing_imports = true diff --git a/pkgs/clan-cli/tests/openapi_client/__init__.py b/pkgs/clan-cli/tests/openapi_client/__init__.py index f46dd78..638483e 100644 --- a/pkgs/clan-cli/tests/openapi_client/__init__.py +++ b/pkgs/clan-cli/tests/openapi_client/__init__.py @@ -17,7 +17,6 @@ __version__ = "1.0.0" # import apis into sdk package -from openapi_client.api.clients_api import ClientsApi from openapi_client.api.default_api import DefaultApi from openapi_client.api.entities_api import EntitiesApi from openapi_client.api.repositories_api import RepositoriesApi @@ -43,6 +42,7 @@ from openapi_client.models.machine import Machine from openapi_client.models.resolution import Resolution from openapi_client.models.service import Service from openapi_client.models.service_create import ServiceCreate +from openapi_client.models.services_by_name import ServicesByName from openapi_client.models.status import Status from openapi_client.models.validation_error import ValidationError from openapi_client.models.validation_error_loc_inner import ValidationErrorLocInner diff --git a/pkgs/clan-cli/tests/openapi_client/api/__init__.py b/pkgs/clan-cli/tests/openapi_client/api/__init__.py index 234e1be..39c3f1b 100644 --- a/pkgs/clan-cli/tests/openapi_client/api/__init__.py +++ b/pkgs/clan-cli/tests/openapi_client/api/__init__.py @@ -1,7 +1,6 @@ # flake8: noqa # import apis into api package -from openapi_client.api.clients_api import ClientsApi from openapi_client.api.default_api import DefaultApi from openapi_client.api.entities_api import EntitiesApi from openapi_client.api.repositories_api import RepositoriesApi diff --git a/pkgs/clan-cli/tests/openapi_client/api/clients_api.py b/pkgs/clan-cli/tests/openapi_client/api/clients_api.py deleted file mode 100644 index 431c420..0000000 --- a/pkgs/clan-cli/tests/openapi_client/api/clients_api.py +++ /dev/null @@ -1,200 +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, StrictStr - -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 ClientsApi: - """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_clients_by_did(self, entity_did : StrictStr, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> List[Service]: # noqa: E501 - """Get Clients By 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_clients_by_did(entity_did, skip, limit, async_req=True) - >>> result = thread.get() - - :param entity_did: (required) - :type entity_did: str - :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_clients_by_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_clients_by_did_with_http_info(entity_did, skip, limit, **kwargs) # noqa: E501 - - @validate_arguments - def get_clients_by_did_with_http_info(self, entity_did : StrictStr, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> ApiResponse: # noqa: E501 - """Get Clients By 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_clients_by_did_with_http_info(entity_did, skip, limit, async_req=True) - >>> result = thread.get() - - :param entity_did: (required) - :type entity_did: str - :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 = [ - 'entity_did', - '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_clients_by_did" % _key - ) - _params[_key] = _val - del _params['kwargs'] - - _collection_formats = {} - - # process the path parameters - _path_params = {} - if _params['entity_did']: - _path_params['entity_did'] = _params['entity_did'] - - - # 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/{entity_did}/clients', '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')) diff --git a/pkgs/clan-cli/tests/openapi_client/api/services_api.py b/pkgs/clan-cli/tests/openapi_client/api/services_api.py index 7e13ea0..4c17330 100644 --- a/pkgs/clan-cli/tests/openapi_client/api/services_api.py +++ b/pkgs/clan-cli/tests/openapi_client/api/services_api.py @@ -24,6 +24,7 @@ from typing import Any, List, Optional, Dict from openapi_client.models.service import Service from openapi_client.models.service_create import ServiceCreate +from openapi_client.models.services_by_name import ServicesByName from openapi_client.api_client import ApiClient from openapi_client.api_response import ApiResponse @@ -631,3 +632,158 @@ class ServicesApi: _request_timeout=_params.get('_request_timeout'), collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) + + @validate_arguments + def get_services_by_name(self, entity_name : StrictStr, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> ServicesByName: # noqa: E501 + """Get Services By Name # 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_services_by_name(entity_name, skip, limit, async_req=True) + >>> result = thread.get() + + :param entity_name: (required) + :type entity_name: str + :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: ServicesByName + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the get_services_by_name_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.get_services_by_name_with_http_info(entity_name, skip, limit, **kwargs) # noqa: E501 + + @validate_arguments + def get_services_by_name_with_http_info(self, entity_name : StrictStr, skip : Optional[StrictInt] = None, limit : Optional[StrictInt] = None, **kwargs) -> ApiResponse: # noqa: E501 + """Get Services By Name # 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_services_by_name_with_http_info(entity_name, skip, limit, async_req=True) + >>> result = thread.get() + + :param entity_name: (required) + :type entity_name: str + :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(ServicesByName, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'entity_name', + '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_services_by_name" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # 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('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': "ServicesByName", + '422': "HTTPValidationError", + } + + return self.api_client.call_api( + '/api/v1/services_by_entity_name', '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')) diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ClientsApi.md b/pkgs/clan-cli/tests/openapi_client/docs/ClientsApi.md deleted file mode 100644 index e232dcd..0000000 --- a/pkgs/clan-cli/tests/openapi_client/docs/ClientsApi.md +++ /dev/null @@ -1,77 +0,0 @@ -# openapi_client.ClientsApi - -All URIs are relative to _http://localhost_ - -| Method | HTTP request | Description | -| ---------------------------------------------------------- | ------------------------------------ | ------------------ | -| [**get_clients_by_did**](ClientsApi.md#get_clients_by_did) | **GET** /api/v1/{entity_did}/clients | Get Clients By Did | - -# **get_clients_by_did** - -> List[Service] get_clients_by_did(entity_did, skip=skip, limit=limit) - -Get Clients By Did - -### 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.ClientsApi(api_client) - entity_did = 'entity_did_example' # str | - skip = 0 # int | (optional) (default to 0) - limit = 100 # int | (optional) (default to 100) - - try: - # Get Clients By Did - api_response = api_instance.get_clients_by_did(entity_did, skip=skip, limit=limit) - print("The response of ClientsApi->get_clients_by_did:\n") - pprint(api_response) - except Exception as e: - print("Exception when calling ClientsApi->get_clients_by_did: %s\n" % e) -``` - -### Parameters - -| Name | Type | Description | Notes | -| -------------- | ------- | ----------- | --------------------------- | -| **entity_did** | **str** | | -| **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) diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md b/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md index 048e944..846a81c 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md @@ -2,12 +2,13 @@ All URIs are relative to _http://localhost_ -| Method | HTTP request | Description | -| ----------------------------------------------------------- | --------------------------------------- | ------------------ | -| [**create_service**](ServicesApi.md#create_service) | **POST** /api/v1/service | Create Service | -| [**delete_service**](ServicesApi.md#delete_service) | **DELETE** /api/v1/{entity_did}/service | Delete Service | -| [**get_all_services**](ServicesApi.md#get_all_services) | **GET** /api/v1/services | Get All Services | -| [**get_service_by_did**](ServicesApi.md#get_service_by_did) | **GET** /api/v1/{entity_did}/service | Get Service By Did | +| Method | HTTP request | Description | +| --------------------------------------------------------------- | --------------------------------------- | -------------------- | +| [**create_service**](ServicesApi.md#create_service) | **POST** /api/v1/service | Create Service | +| [**delete_service**](ServicesApi.md#delete_service) | **DELETE** /api/v1/{entity_did}/service | Delete Service | +| [**get_all_services**](ServicesApi.md#get_all_services) | **GET** /api/v1/services | Get All Services | +| [**get_service_by_did**](ServicesApi.md#get_service_by_did) | **GET** /api/v1/{entity_did}/service | Get Service By Did | +| [**get_services_by_name**](ServicesApi.md#get_services_by_name) | **GET** /api/v1/services_by_entity_name | Get Services By Name | # **create_service** @@ -278,3 +279,73 @@ No authorization required | **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) + +# **get_services_by_name** + +> ServicesByName get_services_by_name(entity_name, skip=skip, limit=limit) + +Get Services By Name + +### Example + +```python +import time +import os +import openapi_client +from openapi_client.models.services_by_name import ServicesByName +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.ServicesApi(api_client) + entity_name = 'entity_name_example' # str | + skip = 0 # int | (optional) (default to 0) + limit = 100 # int | (optional) (default to 100) + + try: + # Get Services By Name + api_response = api_instance.get_services_by_name(entity_name, skip=skip, limit=limit) + print("The response of ServicesApi->get_services_by_name:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling ServicesApi->get_services_by_name: %s\n" % e) +``` + +### Parameters + +| Name | Type | Description | Notes | +| --------------- | ------- | ----------- | --------------------------- | +| **entity_name** | **str** | | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | + +### Return type + +[**ServicesByName**](ServicesByName.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) diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ServicesByName.md b/pkgs/clan-cli/tests/openapi_client/docs/ServicesByName.md new file mode 100644 index 0000000..5d25b1e --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/docs/ServicesByName.md @@ -0,0 +1,28 @@ +# ServicesByName + +## Properties + +| Name | Type | Description | Notes | +| ------------ | ------------------------------- | ----------- | ----- | +| **entity** | [**Entity**](Entity.md) | | +| **services** | [**List[Service]**](Service.md) | | + +## Example + +```python +from openapi_client.models.services_by_name import ServicesByName + +# TODO update the JSON string below +json = "{}" +# create an instance of ServicesByName from a JSON string +services_by_name_instance = ServicesByName.from_json(json) +# print the JSON string representation of the object +print ServicesByName.to_json() + +# convert the object into a dict +services_by_name_dict = services_by_name_instance.to_dict() +# create an instance of ServicesByName from a dict +services_by_name_form_dict = services_by_name.from_dict(services_by_name_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) diff --git a/pkgs/clan-cli/tests/openapi_client/models/__init__.py b/pkgs/clan-cli/tests/openapi_client/models/__init__.py index 4955602..822cc4e 100644 --- a/pkgs/clan-cli/tests/openapi_client/models/__init__.py +++ b/pkgs/clan-cli/tests/openapi_client/models/__init__.py @@ -21,6 +21,7 @@ from openapi_client.models.machine import Machine from openapi_client.models.resolution import Resolution from openapi_client.models.service import Service from openapi_client.models.service_create import ServiceCreate +from openapi_client.models.services_by_name import ServicesByName from openapi_client.models.status import Status from openapi_client.models.validation_error import ValidationError from openapi_client.models.validation_error_loc_inner import ValidationErrorLocInner diff --git a/pkgs/clan-cli/tests/openapi_client/models/services_by_name.py b/pkgs/clan-cli/tests/openapi_client/models/services_by_name.py new file mode 100644 index 0000000..0ee9a85 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/models/services_by_name.py @@ -0,0 +1,85 @@ +# 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 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import List +from pydantic import BaseModel, Field, conlist +from openapi_client.models.entity import Entity +from openapi_client.models.service import Service + +class ServicesByName(BaseModel): + """ + ServicesByName + """ + entity: Entity = Field(...) + services: conlist(Service) = Field(...) + __properties = ["entity", "services"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> ServicesByName: + """Create an instance of ServicesByName from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of entity + if self.entity: + _dict['entity'] = self.entity.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in services (list) + _items = [] + if self.services: + for _item in self.services: + if _item: + _items.append(_item.to_dict()) + _dict['services'] = _items + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> ServicesByName: + """Create an instance of ServicesByName from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return ServicesByName.parse_obj(obj) + + _obj = ServicesByName.parse_obj({ + "entity": Entity.from_dict(obj.get("entity")) if obj.get("entity") is not None else None, + "services": [Service.from_dict(_item) for _item in obj.get("services")] if obj.get("services") is not None else None + }) + return _obj + + diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_clients_api.py b/pkgs/clan-cli/tests/openapi_client/test/test_clients_api.py deleted file mode 100644 index a78453a..0000000 --- a/pkgs/clan-cli/tests/openapi_client/test/test_clients_api.py +++ /dev/null @@ -1,38 +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 unittest - -from openapi_client.api.clients_api import ClientsApi # noqa: E501 - - -class TestClientsApi(unittest.TestCase): - """ClientsApi unit test stubs""" - - def setUp(self) -> None: - self.api = ClientsApi() # noqa: E501 - - def tearDown(self) -> None: - pass - - def test_get_clients_by_did(self) -> None: - """Test case for get_clients_by_did - - Get Clients By Did # noqa: E501 - """ - pass - - -if __name__ == '__main__': - unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_services_api.py b/pkgs/clan-cli/tests/openapi_client/test/test_services_api.py index e92a4d7..b9d196d 100644 --- a/pkgs/clan-cli/tests/openapi_client/test/test_services_api.py +++ b/pkgs/clan-cli/tests/openapi_client/test/test_services_api.py @@ -54,6 +54,13 @@ class TestServicesApi(unittest.TestCase): """ pass + def test_get_services_by_name(self) -> None: + """Test case for get_services_by_name + + Get Services By Name # noqa: E501 + """ + pass + if __name__ == '__main__': unittest.main() diff --git a/pkgs/clan-cli/tests/openapi_client/test/test_services_by_name.py b/pkgs/clan-cli/tests/openapi_client/test/test_services_by_name.py new file mode 100644 index 0000000..b63992b --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/test/test_services_by_name.py @@ -0,0 +1,99 @@ +# 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 unittest +import datetime + +from openapi_client.models.services_by_name import ServicesByName # noqa: E501 + +class TestServicesByName(unittest.TestCase): + """ServicesByName unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> ServicesByName: + """Test ServicesByName + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `ServicesByName` + """ + model = ServicesByName() # noqa: E501 + if include_optional: + return ServicesByName( + entity = openapi_client.models.entity.Entity( + did = 'did:sov:test:1234', + name = 'C1', + ip = '127.0.0.1', + visible = True, + other = {network=Carlos Home Network, roles=[service repository, service prosumer]}, + attached = True, ), + services = [ + openapi_client.models.service.Service( + uuid = '8e285c0c-4e40-430a-a477-26b3b81e30df', + service_name = 'Carlos Printing', + service_type = '3D Printing', + endpoint_url = 'http://127.0.0.1:8000', + status = 'unknown', + other = {action=[register, deregister, delete, create]}, + entity_did = 'did:sov:test:1234', + entity = openapi_client.models.entity.Entity( + did = 'did:sov:test:1234', + name = 'C1', + ip = '127.0.0.1', + visible = True, + other = {network=Carlos Home Network, roles=[service repository, service prosumer]}, + attached = True, ), ) + ] + ) + else: + return ServicesByName( + entity = openapi_client.models.entity.Entity( + did = 'did:sov:test:1234', + name = 'C1', + ip = '127.0.0.1', + visible = True, + other = {network=Carlos Home Network, roles=[service repository, service prosumer]}, + attached = True, ), + services = [ + openapi_client.models.service.Service( + uuid = '8e285c0c-4e40-430a-a477-26b3b81e30df', + service_name = 'Carlos Printing', + service_type = '3D Printing', + endpoint_url = 'http://127.0.0.1:8000', + status = 'unknown', + other = {action=[register, deregister, delete, create]}, + entity_did = 'did:sov:test:1234', + entity = openapi_client.models.entity.Entity( + did = 'did:sov:test:1234', + name = 'C1', + ip = '127.0.0.1', + visible = True, + other = {network=Carlos Home Network, roles=[service repository, service prosumer]}, + attached = True, ), ) + ], + ) + """ + + def testServicesByName(self): + """Test ServicesByName""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/pkgs/ui/src/app/client/[client_name]/page.tsx b/pkgs/ui/src/app/client/[client_name]/page.tsx index 55028e9..259d016 100644 --- a/pkgs/ui/src/app/client/[client_name]/page.tsx +++ b/pkgs/ui/src/app/client/[client_name]/page.tsx @@ -1,9 +1,6 @@ "use client"; import { useEffect, useMemo, useRef, useState } from "react"; -import { - ClientTableConfig, - ServiceTableConfig, -} from "@/config/client_1"; +import { ClientTableConfig, ServiceTableConfig } from "@/config/client_1"; import CustomTable from "@/components/table"; import { Alert, diff --git a/pkgs/ui/src/components/table/index.tsx b/pkgs/ui/src/components/table/index.tsx index 52b8b5f..d0a8b75 100644 --- a/pkgs/ui/src/components/table/index.tsx +++ b/pkgs/ui/src/components/table/index.tsx @@ -25,7 +25,7 @@ const CustomTable = ({ configuration, data, loading, key }: ICustomTable) => { render?: (param: any) => void | undefined, ) => { let renderedValue = value; - console.log(cellKey) + console.log(cellKey); // cover use case if the data is an array if (Array.isArray(value)) renderedValue = value.join(", "); @@ -56,12 +56,18 @@ const CustomTable = ({ configuration, data, loading, key }: ICustomTable) => { {data.map((data: any, rowIndex: number) => ( - {configuration.map((column: CustomTableConfiguration, columnIndex: number) => { - const cellValue: any = data[column.key]; - const cellKey = key + ":" + column.key + ":" + rowIndex; - const renderComponent = column?.render; - return renderTableCell(cellValue, cellKey + ":" + columnIndex, renderComponent); - })} + {configuration.map( + (column: CustomTableConfiguration, columnIndex: number) => { + const cellValue: any = data[column.key]; + const cellKey = key + ":" + column.key + ":" + rowIndex; + const renderComponent = column?.render; + return renderTableCell( + cellValue, + cellKey + ":" + columnIndex, + renderComponent, + ); + }, + )} ))}