From e47b0b4911bd32ef9ab5a6fe07830633aafa1fdb Mon Sep 17 00:00:00 2001 From: Luis-Hebendanz Date: Sun, 14 Jan 2024 17:01:14 +0100 Subject: [PATCH 1/2] Added usage field to service --- .../clan_cli/webui/routers/endpoints.py | 16 +- pkgs/clan-cli/clan_cli/webui/schemas.py | 17 +- pkgs/clan-cli/clan_cli/webui/sql_crud.py | 102 +++++++++- pkgs/clan-cli/clan_cli/webui/sql_models.py | 16 ++ .../clan-cli/tests/openapi_client/__init__.py | 3 + .../tests/openapi_client/api/__init__.py | 1 + .../tests/openapi_client/api/default_api.py | 130 ++++++++++++ .../tests/openapi_client/api/entities_api.py | 139 ------------- .../openapi_client/api/repositories_api.py | 192 ++++++++++++++++++ .../tests/openapi_client/api/services_api.py | 155 ++++++++++++++ .../tests/openapi_client/docs/DefaultApi.md | 72 ++++++- .../tests/openapi_client/docs/EntitiesApi.md | 137 ++++--------- .../openapi_client/docs/RepositoriesApi.md | 75 +++++++ .../tests/openapi_client/docs/Resolution.md | 1 - .../tests/openapi_client/docs/Service.md | 20 +- .../openapi_client/docs/ServiceCreate.md | 19 +- .../tests/openapi_client/docs/ServiceUsage.md | 28 +++ .../openapi_client/docs/ServiceUsageCreate.md | 28 +++ .../tests/openapi_client/docs/ServicesApi.md | 102 ++++++++-- .../tests/openapi_client/models/__init__.py | 2 + .../tests/openapi_client/models/resolution.py | 8 +- .../tests/openapi_client/models/service.py | 20 +- .../openapi_client/models/service_create.py | 18 +- .../openapi_client/models/service_usage.py | 73 +++++++ .../models/service_usage_create.py | 73 +++++++ pkgs/clan-cli/tests/test_db_api.py | 1 + 26 files changed, 1140 insertions(+), 308 deletions(-) create mode 100644 pkgs/clan-cli/tests/openapi_client/api/repositories_api.py create mode 100644 pkgs/clan-cli/tests/openapi_client/docs/RepositoriesApi.md create mode 100644 pkgs/clan-cli/tests/openapi_client/docs/ServiceUsage.md create mode 100644 pkgs/clan-cli/tests/openapi_client/docs/ServiceUsageCreate.md create mode 100644 pkgs/clan-cli/tests/openapi_client/models/service_usage.py create mode 100644 pkgs/clan-cli/tests/openapi_client/models/service_usage_create.py diff --git a/pkgs/clan-cli/clan_cli/webui/routers/endpoints.py b/pkgs/clan-cli/clan_cli/webui/routers/endpoints.py index 2465b69..97a01ff 100644 --- a/pkgs/clan-cli/clan_cli/webui/routers/endpoints.py +++ b/pkgs/clan-cli/clan_cli/webui/routers/endpoints.py @@ -18,6 +18,7 @@ from ..schemas import ( Role, Service, ServiceCreate, + ServiceUsageCreate, ) from ..tags import Tags @@ -35,8 +36,16 @@ log = logging.getLogger(__name__) def create_service( service: ServiceCreate, db: Session = Depends(sql_db.get_db) ) -> Service: - # todo checken ob schon da ... - return sql_crud.create_service(db=db, service=service) + services = sql_crud.create_service(db=db, service=service) + return services + + +@router.post("/api/v1/service_usage", response_model=Service, tags=[Tags.services]) +def add_service_usage( + usage: ServiceUsageCreate, service_uuid: str, db: Session = Depends(sql_db.get_db) +) -> Service: + service = sql_crud.add_service_usage(db, service_uuid, usage) + return service @router.get("/api/v1/services", response_model=List[Service], tags=[Tags.services]) @@ -141,9 +150,6 @@ def detach_entity( limit: int = 100, db: Session = Depends(sql_db.get_db), ) -> dict[str, str]: - entity = sql_crud.get_entity_by_did(db, did=entity_did) - if entity is None: - raise ClanError(f"Entity with did '{entity_did}' not found") sql_crud.set_stop_health_task(db, entity_did, True) return {"message": f"Detached {entity_did} successfully"} diff --git a/pkgs/clan-cli/clan_cli/webui/schemas.py b/pkgs/clan-cli/clan_cli/webui/schemas.py index fbe0e73..ba1e7ac 100644 --- a/pkgs/clan-cli/clan_cli/webui/schemas.py +++ b/pkgs/clan-cli/clan_cli/webui/schemas.py @@ -78,6 +78,19 @@ class Entity(EntityBase): # Service # # # ######################### +class ServiceUsageBase(BaseModel): + times_consumed: int = Field(..., example=2) + + +class ServiceUsageCreate(ServiceUsageBase): + consumer_entity_did: str = Field(..., example="did:sov:test:120") + + +class ServiceUsage(ServiceUsageCreate): + class Config: + orm_mode = True + + class ServiceBase(BaseModel): uuid: str = Field(..., example="8e285c0c-4e40-430a-a477-26b3b81e30df") service_name: str = Field(..., example="Carlos Printing") @@ -91,10 +104,12 @@ class ServiceBase(BaseModel): class ServiceCreate(ServiceBase): entity_did: str = Field(..., example="did:sov:test:120") + usage: List[ServiceUsageCreate] -class Service(ServiceCreate): +class Service(ServiceBase): entity: Entity + usage: List[ServiceUsage] class Config: orm_mode = True diff --git a/pkgs/clan-cli/clan_cli/webui/sql_crud.py b/pkgs/clan-cli/clan_cli/webui/sql_crud.py index 81c81de..3eb5591 100644 --- a/pkgs/clan-cli/clan_cli/webui/sql_crud.py +++ b/pkgs/clan-cli/clan_cli/webui/sql_crud.py @@ -7,21 +7,101 @@ from sqlalchemy.sql.expression import true from ..errors import ClanError from . import schemas, sql_models + ######################### # # # service # # # ######################### - - def create_service(db: Session, service: schemas.ServiceCreate) -> sql_models.Service: - db_service = sql_models.Service(**service.dict()) + if get_entity_by_did(db, service.entity_did) is None: + raise ClanError(f"Entity with did '{service.entity_did}' not found") + if get_service_by_uuid(db, service.uuid) is not None: + raise ClanError(f"Service with uuid '{service.uuid}' already exists") + db_service = sql_models.Service( + uuid=service.uuid, + service_name=service.service_name, + service_type=service.service_type, + endpoint_url=service.endpoint_url, + status=service.status, + other=service.other, + entity_did=service.entity_did, + ) + db_usage = [] + for usage in service.usage: + db_usage.append( + sql_models.ServiceUsage( + times_consumed=usage.times_consumed, + consumer_entity_did=usage.consumer_entity_did, + ) + ) + db_service.usage = db_usage db.add(db_service) db.commit() db.refresh(db_service) return db_service +def set_service_usage( + db: Session, service_uuid: str, usages: List[schemas.ServiceUsageCreate] +) -> sql_models.Service: + db_service = get_service_by_uuid(db, service_uuid) + if db_service is None: + raise ClanError(f"Service with uuid '{service_uuid}' not found") + db_usage = [] + for usage in usages: + db_usage.append( + sql_models.ServiceUsage( + times_consumed=usage.times_consumed, + consumer_entity_did=usage.consumer_entity_did, + ) + ) + db_service.usage = db_usage + db.add(db_service) + db.commit() + db.refresh(db_service) + return db_service + + +def add_service_usage( + db: Session, service_uuid: str, usage: schemas.ServiceUsageCreate +) -> sql_models.Service: + db_service = get_service_by_uuid(db, service_uuid) + if db_service is None: + raise ClanError(f"Service with uuid '{service_uuid}' not found") + db_service.usage.append( + sql_models.ServiceUsage( + times_consumed=usage.times_consumed, + consumer_entity_did=usage.consumer_entity_did, + ) + ) + db.add(db_service) + db.commit() + db.refresh(db_service) + return db_service + + +def increment_service_usage( + db: Session, service_uuid: str, consumer_entity_did: str +) -> sql_models.ServiceUsage: + db_service = get_service_by_uuid(db, service_uuid) + if db_service is None: + raise ClanError(f"Service with uuid '{service_uuid}' not found") + # TODO: Make a query for this + for usage in db_service.usage: + if usage.consumer_entity_did == consumer_entity_did: + usage.times_consumed += 1 + break + db.add(db_service) + db.commit() + db.refresh(db_service) + return db_service + + +def get_service_by_uuid(db: Session, uuid: str) -> Optional[sql_models.Service]: + return db.query(sql_models.Service).filter(sql_models.Service.uuid == uuid).first() + + def get_services( db: Session, skip: int = 0, limit: int = 100 ) -> List[sql_models.Service]: @@ -65,6 +145,10 @@ def get_services_without_entity_id( # # ######################### def create_entity(db: Session, entity: schemas.EntityCreate) -> sql_models.Entity: + if get_entity_by_did(db, entity.did) is not None: + raise ClanError(f"Entity with did '{entity.did}' already exists") + if get_entity_by_name_or_did(db, entity.name) is not None: + raise ClanError(f"Entity with name '{entity.name}' already exists") db_entity = sql_models.Entity( did=entity.did, name=entity.name, @@ -142,7 +226,9 @@ def get_attached_entities( # Returns same entity if setting didnt changed something -def set_stop_health_task(db: Session, entity_did: str, value: bool) -> None: +def set_stop_health_task( + db: Session, entity_did: str, value: bool +) -> sql_models.Entity: db_entity = get_entity_by_did(db, entity_did) if db_entity is None: raise ClanError(f"Entity with did '{entity_did}' not found") @@ -152,9 +238,13 @@ def set_stop_health_task(db: Session, entity_did: str, value: bool) -> None: # save changes in db db.add(db_entity) db.commit() + db.refresh(db_entity) + return db_entity -def set_attached_by_entity_did(db: Session, entity_did: str, attached: bool) -> None: +def set_attached_by_entity_did( + db: Session, entity_did: str, attached: bool +) -> sql_models.Entity: db_entity = get_entity_by_did(db, entity_did) if db_entity is None: raise ClanError(f"Entity with did '{entity_did}' not found") @@ -164,6 +254,8 @@ def set_attached_by_entity_did(db: Session, entity_did: str, attached: bool) -> # save changes in db db.add(db_entity) db.commit() + db.refresh(db_entity) + return db_entity def delete_entity_by_did(db: Session, did: str) -> None: diff --git a/pkgs/clan-cli/clan_cli/webui/sql_models.py b/pkgs/clan-cli/clan_cli/webui/sql_models.py index b8d09ef..7fc86ab 100644 --- a/pkgs/clan-cli/clan_cli/webui/sql_models.py +++ b/pkgs/clan-cli/clan_cli/webui/sql_models.py @@ -27,6 +27,7 @@ class Entity(Base): ## Relations ## services = relationship("Service", back_populates="entity") roles = relationship("EntityRoles", back_populates="entity") + consumes = relationship("ServiceUsage", back_populates="consumer_entity") class EntityRoles(Base): @@ -41,6 +42,19 @@ class EntityRoles(Base): entity = relationship("Entity", back_populates="roles") +class ServiceUsage(Base): + __tablename__ = "service_usage" + + ## Queryable body ## + id = Column(Integer, primary_key=True, autoincrement=True) + consumer_entity_did = Column(String, ForeignKey("entities.did")) + consumer_entity = relationship("Entity", back_populates="consumes") + times_consumed = Column(Integer, index=True, nullable=False) + + service_uuid = Column(String, ForeignKey("services.uuid")) + service = relationship("Service", back_populates="usage") + + class ServiceAbstract(Base): __abstract__ = True @@ -64,6 +78,8 @@ class Service(ServiceAbstract): entity = relationship("Entity", back_populates="services") entity_did = Column(String, ForeignKey("entities.did")) + usage = relationship("ServiceUsage", back_populates="service") + class Eventmessage(Base): __tablename__ = "eventmessages" diff --git a/pkgs/clan-cli/tests/openapi_client/__init__.py b/pkgs/clan-cli/tests/openapi_client/__init__.py index bf8d04e..318daff 100644 --- a/pkgs/clan-cli/tests/openapi_client/__init__.py +++ b/pkgs/clan-cli/tests/openapi_client/__init__.py @@ -20,6 +20,7 @@ __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 @@ -45,6 +46,8 @@ from openapi_client.models.resolution import Resolution 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.service_usage import ServiceUsage +from openapi_client.models.service_usage_create import ServiceUsageCreate 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 88a80e5..87b34f9 100644 --- a/pkgs/clan-cli/tests/openapi_client/api/__init__.py +++ b/pkgs/clan-cli/tests/openapi_client/api/__init__.py @@ -4,6 +4,7 @@ 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 diff --git a/pkgs/clan-cli/tests/openapi_client/api/default_api.py b/pkgs/clan-cli/tests/openapi_client/api/default_api.py index b64e1d4..4e5e97f 100644 --- a/pkgs/clan-cli/tests/openapi_client/api/default_api.py +++ b/pkgs/clan-cli/tests/openapi_client/api/default_api.py @@ -170,6 +170,136 @@ class DefaultApi: collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) + @validate_arguments + def get_emulated_enpoints(self, **kwargs) -> str: # noqa: E501 + """Get Emulated Enpoints # 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_emulated_enpoints(async_req=True) + >>> result = thread.get() + + :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: str + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the get_emulated_enpoints_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.get_emulated_enpoints_with_http_info(**kwargs) # noqa: E501 + + @validate_arguments + def get_emulated_enpoints_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 + """Get Emulated Enpoints # 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_emulated_enpoints_with_http_info(async_req=True) + >>> result = thread.get() + + :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(str, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + ] + _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_emulated_enpoints" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # 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( + ['text/html']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "str", + } + + return self.api_client.call_api( + '/emulate', '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 health(self, **kwargs) -> Machine: # noqa: E501 """Health # noqa: E501 diff --git a/pkgs/clan-cli/tests/openapi_client/api/entities_api.py b/pkgs/clan-cli/tests/openapi_client/api/entities_api.py index 041bafe..26df8ea 100644 --- a/pkgs/clan-cli/tests/openapi_client/api/entities_api.py +++ b/pkgs/clan-cli/tests/openapi_client/api/entities_api.py @@ -1074,145 +1074,6 @@ class EntitiesApi: collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments - 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_or_did(entity_name_or_did, async_req=True) - >>> result = thread.get() - - :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. - 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: Entity - """ - kwargs['_return_http_data_only'] = True - if '_preload_content' in kwargs: - 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_or_did_with_http_info(entity_name_or_did, **kwargs) # noqa: E501 - - @validate_arguments - 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_or_did_with_http_info(entity_name_or_did, async_req=True) - >>> result = thread.get() - - :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 - 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(Entity, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = [ - 'entity_name_or_did' - ] - _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_name_or_did" % _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_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', {})) - # 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': "Entity", - '422': "HTTPValidationError", - } - - return self.api_client.call_api( - '/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 diff --git a/pkgs/clan-cli/tests/openapi_client/api/repositories_api.py b/pkgs/clan-cli/tests/openapi_client/api/repositories_api.py new file mode 100644 index 0000000..bedb1e3 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/api/repositories_api.py @@ -0,0 +1,192 @@ +# 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')) 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 d8eb462..c3f3f4e 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.service_usage_create import ServiceUsageCreate from openapi_client.api_client import ApiClient from openapi_client.api_response import ApiResponse @@ -45,6 +46,160 @@ class ServicesApi: api_client = ApiClient.get_default() self.api_client = api_client + @validate_arguments + def add_service_usage(self, service_uuid : StrictStr, service_usage_create : ServiceUsageCreate, **kwargs) -> Service: # noqa: E501 + """Add Service Usage # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.add_service_usage(service_uuid, service_usage_create, async_req=True) + >>> result = thread.get() + + :param service_uuid: (required) + :type service_uuid: str + :param service_usage_create: (required) + :type service_usage_create: ServiceUsageCreate + :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: Service + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the add_service_usage_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.add_service_usage_with_http_info(service_uuid, service_usage_create, **kwargs) # noqa: E501 + + @validate_arguments + def add_service_usage_with_http_info(self, service_uuid : StrictStr, service_usage_create : ServiceUsageCreate, **kwargs) -> ApiResponse: # noqa: E501 + """Add Service Usage # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.add_service_usage_with_http_info(service_uuid, service_usage_create, async_req=True) + >>> result = thread.get() + + :param service_uuid: (required) + :type service_uuid: str + :param service_usage_create: (required) + :type service_usage_create: ServiceUsageCreate + :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(Service, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'service_uuid', + 'service_usage_create' + ] + _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 add_service_usage" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + if _params.get('service_uuid') is not None: # noqa: E501 + _query_params.append(('service_uuid', _params['service_uuid'])) + + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['service_usage_create'] is not None: + _body_params = _params['service_usage_create'] + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "Service", + '422': "HTTPValidationError", + } + + return self.api_client.call_api( + '/api/v1/service_usage', 'POST', + _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 create_service(self, service_create : ServiceCreate, **kwargs) -> Service: # noqa: E501 """Create Service # noqa: E501 diff --git a/pkgs/clan-cli/tests/openapi_client/docs/DefaultApi.md b/pkgs/clan-cli/tests/openapi_client/docs/DefaultApi.md index aef64f7..eff1088 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/DefaultApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/DefaultApi.md @@ -2,11 +2,12 @@ All URIs are relative to _http://localhost_ -| Method | HTTP request | Description | -| ---------------------------------- | -------------------- | ----------- | -| [**get**](DefaultApi.md#get) | **GET** /ws2_example | Get | -| [**health**](DefaultApi.md#health) | **GET** /health | Health | -| [**root**](DefaultApi.md#root) | **GET** /{path_name} | Root | +| Method | HTTP request | Description | +| ---------------------------------------------------------------- | -------------------- | --------------------- | +| [**get**](DefaultApi.md#get) | **GET** /ws2_example | Get | +| [**get_emulated_enpoints**](DefaultApi.md#get_emulated_enpoints) | **GET** /emulate | Get Emulated Enpoints | +| [**health**](DefaultApi.md#health) | **GET** /health | Health | +| [**root**](DefaultApi.md#root) | **GET** /{path_name} | Root | # **get** @@ -67,6 +68,67 @@ 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_emulated_enpoints** + +> str get_emulated_enpoints() + +Get Emulated Enpoints + +### Example + +```python +import time +import os +import openapi_client +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.DefaultApi(api_client) + + try: + # Get Emulated Enpoints + api_response = api_instance.get_emulated_enpoints() + print("The response of DefaultApi->get_emulated_enpoints:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling DefaultApi->get_emulated_enpoints: %s\n" % e) +``` + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +**str** + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: text/html + +### HTTP response details + +| Status code | Description | Response headers | +| ----------- | ------------------- | ---------------- | +| **200** | Successful Response | - | + +[[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) + # **health** > Machine health() diff --git a/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md b/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md index 4cc9b38..2092729 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/EntitiesApi.md @@ -2,18 +2,17 @@ All URIs are relative to _http://localhost_ -| 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 | +| 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_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** @@ -41,7 +40,7 @@ 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_did = 'did:sov:test:1234' # str | (optional) (default to 'did:sov:test:1234') + entity_did = 'did:sov:test:120' # str | (optional) (default to 'did:sov:test:120') skip = 0 # int | (optional) (default to 0) limit = 100 # int | (optional) (default to 100) @@ -56,11 +55,11 @@ with openapi_client.ApiClient(configuration) as api_client: ### Parameters -| Name | Type | Description | Notes | -| -------------- | ------- | ----------- | --------------------------------------------------- | -| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | -------------------------------------------------- | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:120'] | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | ### Return type @@ -177,7 +176,7 @@ 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_did = 'did:sov:test:1234' # str | (optional) (default to 'did:sov:test:1234') + entity_did = 'did:sov:test:120' # str | (optional) (default to 'did:sov:test:120') try: # Delete Entity @@ -190,9 +189,9 @@ with openapi_client.ApiClient(configuration) as api_client: ### Parameters -| Name | Type | Description | Notes | -| -------------- | ------- | ----------- | --------------------------------------------------- | -| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | -------------------------------------------------- | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:120'] | ### Return type @@ -242,7 +241,7 @@ 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_did = 'did:sov:test:1234' # str | (optional) (default to 'did:sov:test:1234') + entity_did = 'did:sov:test:120' # str | (optional) (default to 'did:sov:test:120') skip = 0 # int | (optional) (default to 0) limit = 100 # int | (optional) (default to 100) @@ -257,11 +256,11 @@ with openapi_client.ApiClient(configuration) as api_client: ### Parameters -| Name | Type | Description | Notes | -| -------------- | ------- | ----------- | --------------------------------------------------- | -| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | -------------------------------------------------- | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:120'] | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | ### Return type @@ -448,7 +447,7 @@ 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_did = 'did:sov:test:1234' # str | (optional) (default to 'did:sov:test:1234') + entity_did = 'did:sov:test:120' # str | (optional) (default to 'did:sov:test:120') try: # Get Entity By Did @@ -461,75 +460,9 @@ with openapi_client.ApiClient(configuration) as api_client: ### Parameters -| Name | Type | Description | Notes | -| -------------- | ------- | ----------- | --------------------------------------------------- | -| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | - -### Return type - -[**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) - -# **get_entity_by_name_or_did** - -> Entity get_entity_by_name_or_did(entity_name_or_did=entity_name_or_did) - -Get Entity By Name Or Did - -### Example - -```python -import time -import os -import openapi_client -from openapi_client.models.entity import Entity -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) - entity_name_or_did = 'C1' # str | (optional) (default to 'C1') - - try: - # 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_or_did: %s\n" % e) -``` - -### Parameters - -| Name | Type | Description | Notes | -| ---------------------- | ------- | ----------- | ------------------------------------ | -| **entity_name_or_did** | **str** | | [optional] [default to 'C1'] | +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | -------------------------------------------------- | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:120'] | ### Return type @@ -646,7 +579,7 @@ 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_did = 'did:sov:test:1234' # str | (optional) (default to 'did:sov:test:1234') + entity_did = 'did:sov:test:120' # str | (optional) (default to 'did:sov:test:120') try: # Is Attached @@ -659,9 +592,9 @@ with openapi_client.ApiClient(configuration) as api_client: ### Parameters -| Name | Type | Description | Notes | -| -------------- | ------- | ----------- | --------------------------------------------------- | -| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | -------------------------------------------------- | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:120'] | ### Return type diff --git a/pkgs/clan-cli/tests/openapi_client/docs/RepositoriesApi.md b/pkgs/clan-cli/tests/openapi_client/docs/RepositoriesApi.md new file mode 100644 index 0000000..ff735f0 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/docs/RepositoriesApi.md @@ -0,0 +1,75 @@ +# 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) diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md b/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md index 27928d5..2f849e8 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Resolution.md @@ -9,7 +9,6 @@ | **resolved_did** | **str** | | | **other** | **object** | | | **timestamp** | **datetime** | | -| **id** | **int** | | ## Example diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Service.md b/pkgs/clan-cli/tests/openapi_client/docs/Service.md index 5798f74..de14631 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Service.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Service.md @@ -2,16 +2,16 @@ ## Properties -| Name | Type | Description | Notes | -| ---------------- | ----------------------- | ----------- | ----- | -| **uuid** | **str** | | -| **service_name** | **str** | | -| **service_type** | **str** | | -| **endpoint_url** | **str** | | -| **status** | **str** | | -| **other** | **object** | | -| **entity_did** | **str** | | -| **entity** | [**Entity**](Entity.md) | | +| Name | Type | Description | Notes | +| ---------------- | ----------------------------------------- | ----------- | ----- | +| **uuid** | **str** | | +| **service_name** | **str** | | +| **service_type** | **str** | | +| **endpoint_url** | **str** | | +| **status** | **str** | | +| **other** | **object** | | +| **entity** | [**Entity**](Entity.md) | | +| **usage** | [**List[ServiceUsage]**](ServiceUsage.md) | | ## Example diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md b/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md index 7843b1a..e490a6d 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ServiceCreate.md @@ -2,15 +2,16 @@ ## Properties -| Name | Type | Description | Notes | -| ---------------- | ---------- | ----------- | ----- | -| **uuid** | **str** | | -| **service_name** | **str** | | -| **service_type** | **str** | | -| **endpoint_url** | **str** | | -| **status** | **str** | | -| **other** | **object** | | -| **entity_did** | **str** | | +| Name | Type | Description | Notes | +| ---------------- | ----------------------------------------------------- | ----------- | ----- | +| **uuid** | **str** | | +| **service_name** | **str** | | +| **service_type** | **str** | | +| **endpoint_url** | **str** | | +| **status** | **str** | | +| **other** | **object** | | +| **entity_did** | **str** | | +| **usage** | [**List[ServiceUsageCreate]**](ServiceUsageCreate.md) | | ## Example diff --git a/pkgs/clan-cli/tests/openapi_client/docs/ServiceUsage.md b/pkgs/clan-cli/tests/openapi_client/docs/ServiceUsage.md new file mode 100644 index 0000000..86059b8 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/docs/ServiceUsage.md @@ -0,0 +1,28 @@ +# ServiceUsage + +## Properties + +| Name | Type | Description | Notes | +| ----------------------- | ------- | ----------- | ----- | +| **times_consumed** | **int** | | +| **consumer_entity_did** | **str** | | + +## Example + +```python +from openapi_client.models.service_usage import ServiceUsage + +# TODO update the JSON string below +json = "{}" +# create an instance of ServiceUsage from a JSON string +service_usage_instance = ServiceUsage.from_json(json) +# print the JSON string representation of the object +print ServiceUsage.to_json() + +# convert the object into a dict +service_usage_dict = service_usage_instance.to_dict() +# create an instance of ServiceUsage from a dict +service_usage_form_dict = service_usage.from_dict(service_usage_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/docs/ServiceUsageCreate.md b/pkgs/clan-cli/tests/openapi_client/docs/ServiceUsageCreate.md new file mode 100644 index 0000000..d897943 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/docs/ServiceUsageCreate.md @@ -0,0 +1,28 @@ +# ServiceUsageCreate + +## Properties + +| Name | Type | Description | Notes | +| ----------------------- | ------- | ----------- | ----- | +| **times_consumed** | **int** | | +| **consumer_entity_did** | **str** | | + +## Example + +```python +from openapi_client.models.service_usage_create import ServiceUsageCreate + +# TODO update the JSON string below +json = "{}" +# create an instance of ServiceUsageCreate from a JSON string +service_usage_create_instance = ServiceUsageCreate.from_json(json) +# print the JSON string representation of the object +print ServiceUsageCreate.to_json() + +# convert the object into a dict +service_usage_create_dict = service_usage_create_instance.to_dict() +# create an instance of ServiceUsageCreate from a dict +service_usage_create_form_dict = service_usage_create.from_dict(service_usage_create_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/docs/ServicesApi.md b/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md index 006615a..cdcd92b 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/ServicesApi.md @@ -4,12 +4,82 @@ All URIs are relative to _http://localhost_ | Method | HTTP request | Description | | ----------------------------------------------------------------------------- | --------------------------------------- | --------------------------- | +| [**add_service_usage**](ServicesApi.md#add_service_usage) | **POST** /api/v1/service_usage | Add Service Usage | | [**create_service**](ServicesApi.md#create_service) | **POST** /api/v1/service | Create Service | | [**delete_service**](ServicesApi.md#delete_service) | **DELETE** /api/v1/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/service | Get Service By Did | | [**get_services_without_entity**](ServicesApi.md#get_services_without_entity) | **GET** /api/v1/services_without_entity | Get Services Without Entity | +# **add_service_usage** + +> Service add_service_usage(service_uuid, service_usage_create) + +Add Service Usage + +### Example + +```python +import time +import os +import openapi_client +from openapi_client.models.service import Service +from openapi_client.models.service_usage_create import ServiceUsageCreate +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) + service_uuid = 'service_uuid_example' # str | + service_usage_create = openapi_client.ServiceUsageCreate() # ServiceUsageCreate | + + try: + # Add Service Usage + api_response = api_instance.add_service_usage(service_uuid, service_usage_create) + print("The response of ServicesApi->add_service_usage:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling ServicesApi->add_service_usage: %s\n" % e) +``` + +### Parameters + +| Name | Type | Description | Notes | +| ------------------------ | ----------------------------------------------- | ----------- | ----- | +| **service_uuid** | **str** | | +| **service_usage_create** | [**ServiceUsageCreate**](ServiceUsageCreate.md) | | + +### Return type + +[**Service**](Service.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **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) + # **create_service** > Service create_service(service_create) @@ -103,7 +173,7 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.ServicesApi(api_client) - entity_did = 'did:sov:test:1234' # str | (optional) (default to 'did:sov:test:1234') + entity_did = 'did:sov:test:120' # str | (optional) (default to 'did:sov:test:120') try: # Delete Service @@ -116,9 +186,9 @@ with openapi_client.ApiClient(configuration) as api_client: ### Parameters -| Name | Type | Description | Notes | -| -------------- | ------- | ----------- | --------------------------------------------------- | -| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | -------------------------------------------------- | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:120'] | ### Return type @@ -237,7 +307,7 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.ServicesApi(api_client) - entity_did = 'did:sov:test:1234' # str | (optional) (default to 'did:sov:test:1234') + entity_did = 'did:sov:test:120' # str | (optional) (default to 'did:sov:test:120') skip = 0 # int | (optional) (default to 0) limit = 100 # int | (optional) (default to 100) @@ -252,11 +322,11 @@ with openapi_client.ApiClient(configuration) as api_client: ### Parameters -| Name | Type | Description | Notes | -| -------------- | ------- | ----------- | --------------------------------------------------- | -| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | -------------------------------------------------- | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:120'] | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | ### Return type @@ -307,7 +377,7 @@ configuration = openapi_client.Configuration( with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = openapi_client.ServicesApi(api_client) - entity_did = 'did:sov:test:1234' # str | (optional) (default to 'did:sov:test:1234') + entity_did = 'did:sov:test:120' # str | (optional) (default to 'did:sov:test:120') skip = 0 # int | (optional) (default to 0) limit = 100 # int | (optional) (default to 100) @@ -322,11 +392,11 @@ with openapi_client.ApiClient(configuration) as api_client: ### Parameters -| Name | Type | Description | Notes | -| -------------- | ------- | ----------- | --------------------------------------------------- | -| **entity_did** | **str** | | [optional] [default to 'did:sov:test:1234'] | -| **skip** | **int** | | [optional] [default to 0] | -| **limit** | **int** | | [optional] [default to 100] | +| Name | Type | Description | Notes | +| -------------- | ------- | ----------- | -------------------------------------------------- | +| **entity_did** | **str** | | [optional] [default to 'did:sov:test:120'] | +| **skip** | **int** | | [optional] [default to 0] | +| **limit** | **int** | | [optional] [default to 100] | ### Return type diff --git a/pkgs/clan-cli/tests/openapi_client/models/__init__.py b/pkgs/clan-cli/tests/openapi_client/models/__init__.py index b211606..e6f0240 100644 --- a/pkgs/clan-cli/tests/openapi_client/models/__init__.py +++ b/pkgs/clan-cli/tests/openapi_client/models/__init__.py @@ -24,6 +24,8 @@ from openapi_client.models.resolution import Resolution 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.service_usage import ServiceUsage +from openapi_client.models.service_usage_create import ServiceUsageCreate 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/resolution.py b/pkgs/clan-cli/tests/openapi_client/models/resolution.py index 05d480b..7de1d12 100644 --- a/pkgs/clan-cli/tests/openapi_client/models/resolution.py +++ b/pkgs/clan-cli/tests/openapi_client/models/resolution.py @@ -19,7 +19,7 @@ import json from datetime import datetime from typing import Any, Dict -from pydantic import BaseModel, Field, StrictInt, StrictStr +from pydantic import BaseModel, Field, StrictStr class Resolution(BaseModel): """ @@ -30,8 +30,7 @@ class Resolution(BaseModel): resolved_did: StrictStr = Field(...) other: Dict[str, Any] = Field(...) timestamp: datetime = Field(...) - id: StrictInt = Field(...) - __properties = ["requester_name", "requester_did", "resolved_did", "other", "timestamp", "id"] + __properties = ["requester_name", "requester_did", "resolved_did", "other", "timestamp"] class Config: """Pydantic configuration""" @@ -73,8 +72,7 @@ class Resolution(BaseModel): "requester_did": obj.get("requester_did"), "resolved_did": obj.get("resolved_did"), "other": obj.get("other"), - "timestamp": obj.get("timestamp"), - "id": obj.get("id") + "timestamp": obj.get("timestamp") }) return _obj diff --git a/pkgs/clan-cli/tests/openapi_client/models/service.py b/pkgs/clan-cli/tests/openapi_client/models/service.py index 9d85092..68b5784 100644 --- a/pkgs/clan-cli/tests/openapi_client/models/service.py +++ b/pkgs/clan-cli/tests/openapi_client/models/service.py @@ -18,9 +18,10 @@ import re # noqa: F401 import json -from typing import Any, Dict -from pydantic import BaseModel, Field, StrictStr +from typing import Any, Dict, List +from pydantic import BaseModel, Field, StrictStr, conlist from openapi_client.models.entity import Entity +from openapi_client.models.service_usage import ServiceUsage class Service(BaseModel): """ @@ -32,9 +33,9 @@ class Service(BaseModel): endpoint_url: StrictStr = Field(...) status: StrictStr = Field(...) other: Dict[str, Any] = Field(...) - entity_did: StrictStr = Field(...) entity: Entity = Field(...) - __properties = ["uuid", "service_name", "service_type", "endpoint_url", "status", "other", "entity_did", "entity"] + usage: conlist(ServiceUsage) = Field(...) + __properties = ["uuid", "service_name", "service_type", "endpoint_url", "status", "other", "entity", "usage"] class Config: """Pydantic configuration""" @@ -63,6 +64,13 @@ class Service(BaseModel): # 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 usage (list) + _items = [] + if self.usage: + for _item in self.usage: + if _item: + _items.append(_item.to_dict()) + _dict['usage'] = _items return _dict @classmethod @@ -81,8 +89,8 @@ class Service(BaseModel): "endpoint_url": obj.get("endpoint_url"), "status": obj.get("status"), "other": obj.get("other"), - "entity_did": obj.get("entity_did"), - "entity": Entity.from_dict(obj.get("entity")) if obj.get("entity") is not None else None + "entity": Entity.from_dict(obj.get("entity")) if obj.get("entity") is not None else None, + "usage": [ServiceUsage.from_dict(_item) for _item in obj.get("usage")] if obj.get("usage") is not None else None }) return _obj diff --git a/pkgs/clan-cli/tests/openapi_client/models/service_create.py b/pkgs/clan-cli/tests/openapi_client/models/service_create.py index 348695e..1bd4162 100644 --- a/pkgs/clan-cli/tests/openapi_client/models/service_create.py +++ b/pkgs/clan-cli/tests/openapi_client/models/service_create.py @@ -18,8 +18,9 @@ import re # noqa: F401 import json -from typing import Any, Dict -from pydantic import BaseModel, Field, StrictStr +from typing import Any, Dict, List +from pydantic import BaseModel, Field, StrictStr, conlist +from openapi_client.models.service_usage_create import ServiceUsageCreate class ServiceCreate(BaseModel): """ @@ -32,7 +33,8 @@ class ServiceCreate(BaseModel): status: StrictStr = Field(...) other: Dict[str, Any] = Field(...) entity_did: StrictStr = Field(...) - __properties = ["uuid", "service_name", "service_type", "endpoint_url", "status", "other", "entity_did"] + usage: conlist(ServiceUsageCreate) = Field(...) + __properties = ["uuid", "service_name", "service_type", "endpoint_url", "status", "other", "entity_did", "usage"] class Config: """Pydantic configuration""" @@ -58,6 +60,13 @@ class ServiceCreate(BaseModel): exclude={ }, exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of each item in usage (list) + _items = [] + if self.usage: + for _item in self.usage: + if _item: + _items.append(_item.to_dict()) + _dict['usage'] = _items return _dict @classmethod @@ -76,7 +85,8 @@ class ServiceCreate(BaseModel): "endpoint_url": obj.get("endpoint_url"), "status": obj.get("status"), "other": obj.get("other"), - "entity_did": obj.get("entity_did") + "entity_did": obj.get("entity_did"), + "usage": [ServiceUsageCreate.from_dict(_item) for _item in obj.get("usage")] if obj.get("usage") is not None else None }) return _obj diff --git a/pkgs/clan-cli/tests/openapi_client/models/service_usage.py b/pkgs/clan-cli/tests/openapi_client/models/service_usage.py new file mode 100644 index 0000000..c5cae78 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/models/service_usage.py @@ -0,0 +1,73 @@ +# 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 pydantic import BaseModel, Field, StrictInt, StrictStr + +class ServiceUsage(BaseModel): + """ + ServiceUsage + """ + times_consumed: StrictInt = Field(...) + consumer_entity_did: StrictStr = Field(...) + __properties = ["times_consumed", "consumer_entity_did"] + + 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) -> ServiceUsage: + """Create an instance of ServiceUsage 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) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> ServiceUsage: + """Create an instance of ServiceUsage from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return ServiceUsage.parse_obj(obj) + + _obj = ServiceUsage.parse_obj({ + "times_consumed": obj.get("times_consumed"), + "consumer_entity_did": obj.get("consumer_entity_did") + }) + return _obj + + diff --git a/pkgs/clan-cli/tests/openapi_client/models/service_usage_create.py b/pkgs/clan-cli/tests/openapi_client/models/service_usage_create.py new file mode 100644 index 0000000..a2199e3 --- /dev/null +++ b/pkgs/clan-cli/tests/openapi_client/models/service_usage_create.py @@ -0,0 +1,73 @@ +# 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 pydantic import BaseModel, Field, StrictInt, StrictStr + +class ServiceUsageCreate(BaseModel): + """ + ServiceUsageCreate + """ + times_consumed: StrictInt = Field(...) + consumer_entity_did: StrictStr = Field(...) + __properties = ["times_consumed", "consumer_entity_did"] + + 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) -> ServiceUsageCreate: + """Create an instance of ServiceUsageCreate 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) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> ServiceUsageCreate: + """Create an instance of ServiceUsageCreate from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return ServiceUsageCreate.parse_obj(obj) + + _obj = ServiceUsageCreate.parse_obj({ + "times_consumed": obj.get("times_consumed"), + "consumer_entity_did": obj.get("consumer_entity_did") + }) + return _obj + + diff --git a/pkgs/clan-cli/tests/test_db_api.py b/pkgs/clan-cli/tests/test_db_api.py index 6e2911b..390c4e2 100644 --- a/pkgs/clan-cli/tests/test_db_api.py +++ b/pkgs/clan-cli/tests/test_db_api.py @@ -83,6 +83,7 @@ def create_service(idx: int, entity: Entity) -> ServiceCreate: status="unknown", other={"action": ["register", "deregister", "delete", "create"]}, entity_did=entity.did, + usage=[], ) return se From 390ded6dff67d30b207a09a6f4e401ae5d59b64a Mon Sep 17 00:00:00 2001 From: Luis-Hebendanz Date: Mon, 15 Jan 2024 15:57:31 +0100 Subject: [PATCH 2/2] Fixed missing entity_did in ServiceBase --- pkgs/clan-cli/clan_cli/webui/schemas.py | 4 +--- pkgs/clan-cli/tests/openapi_client/docs/Service.md | 2 +- pkgs/clan-cli/tests/openapi_client/models/service.py | 10 +++------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/pkgs/clan-cli/clan_cli/webui/schemas.py b/pkgs/clan-cli/clan_cli/webui/schemas.py index ba1e7ac..e2508b9 100644 --- a/pkgs/clan-cli/clan_cli/webui/schemas.py +++ b/pkgs/clan-cli/clan_cli/webui/schemas.py @@ -100,15 +100,14 @@ class ServiceBase(BaseModel): other: dict = Field( ..., example={"action": ["register", "deregister", "delete", "create"]} ) + entity_did: str = Field(..., example="did:sov:test:120") class ServiceCreate(ServiceBase): - entity_did: str = Field(..., example="did:sov:test:120") usage: List[ServiceUsageCreate] class Service(ServiceBase): - entity: Entity usage: List[ServiceUsage] class Config: @@ -116,7 +115,6 @@ class Service(ServiceBase): class ServicesByName(BaseModel): - entity: Entity services: List[Service] class Config: diff --git a/pkgs/clan-cli/tests/openapi_client/docs/Service.md b/pkgs/clan-cli/tests/openapi_client/docs/Service.md index de14631..023e28c 100644 --- a/pkgs/clan-cli/tests/openapi_client/docs/Service.md +++ b/pkgs/clan-cli/tests/openapi_client/docs/Service.md @@ -10,7 +10,7 @@ | **endpoint_url** | **str** | | | **status** | **str** | | | **other** | **object** | | -| **entity** | [**Entity**](Entity.md) | | +| **entity_did** | **str** | | | **usage** | [**List[ServiceUsage]**](ServiceUsage.md) | | ## Example diff --git a/pkgs/clan-cli/tests/openapi_client/models/service.py b/pkgs/clan-cli/tests/openapi_client/models/service.py index 68b5784..18fab79 100644 --- a/pkgs/clan-cli/tests/openapi_client/models/service.py +++ b/pkgs/clan-cli/tests/openapi_client/models/service.py @@ -20,7 +20,6 @@ import json from typing import Any, Dict, List from pydantic import BaseModel, Field, StrictStr, conlist -from openapi_client.models.entity import Entity from openapi_client.models.service_usage import ServiceUsage class Service(BaseModel): @@ -33,9 +32,9 @@ class Service(BaseModel): endpoint_url: StrictStr = Field(...) status: StrictStr = Field(...) other: Dict[str, Any] = Field(...) - entity: Entity = Field(...) + entity_did: StrictStr = Field(...) usage: conlist(ServiceUsage) = Field(...) - __properties = ["uuid", "service_name", "service_type", "endpoint_url", "status", "other", "entity", "usage"] + __properties = ["uuid", "service_name", "service_type", "endpoint_url", "status", "other", "entity_did", "usage"] class Config: """Pydantic configuration""" @@ -61,9 +60,6 @@ class Service(BaseModel): 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 usage (list) _items = [] if self.usage: @@ -89,7 +85,7 @@ class Service(BaseModel): "endpoint_url": obj.get("endpoint_url"), "status": obj.get("status"), "other": obj.get("other"), - "entity": Entity.from_dict(obj.get("entity")) if obj.get("entity") is not None else None, + "entity_did": obj.get("entity_did"), "usage": [ServiceUsage.from_dict(_item) for _item in obj.get("usage")] if obj.get("usage") is not None else None }) return _obj