Added usage field to service #53

Merged
merge-bot merged 2 commits from Qubasa-main into main 2024-01-15 15:11:05 +00:00
26 changed files with 1142 additions and 316 deletions

View File

@@ -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"}

View File

@@ -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")
@@ -87,21 +100,21 @@ class ServiceBase(BaseModel):
other: dict = Field(
..., example={"action": ["register", "deregister", "delete", "create"]}
)
class ServiceCreate(ServiceBase):
entity_did: str = Field(..., example="did:sov:test:120")
class Service(ServiceCreate):
entity: Entity
class ServiceCreate(ServiceBase):
usage: List[ServiceUsageCreate]
class Service(ServiceBase):
usage: List[ServiceUsage]
class Config:
orm_mode = True
class ServicesByName(BaseModel):
entity: Entity
services: List[Service]
class Config:

View File

@@ -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:

View File

@@ -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"

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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'))

View File

@@ -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

View File

@@ -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()

View File

@@ -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

View File

@@ -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)

View File

@@ -9,7 +9,6 @@
| **resolved_did** | **str** | |
| **other** | **object** | |
| **timestamp** | **datetime** | |
| **id** | **int** | |
## Example

View File

@@ -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_did** | **str** | |
| **usage** | [**List[ServiceUsage]**](ServiceUsage.md) | |
## Example

View File

@@ -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

View File

@@ -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)

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -18,9 +18,9 @@ import re # noqa: F401
import json
from typing import Any, Dict
from pydantic import BaseModel, Field, StrictStr
from openapi_client.models.entity import Entity
from typing import Any, Dict, List
from pydantic import BaseModel, Field, StrictStr, conlist
from openapi_client.models.service_usage import ServiceUsage
class Service(BaseModel):
"""
@@ -33,8 +33,8 @@ class Service(BaseModel):
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_did", "usage"]
class Config:
"""Pydantic configuration"""
@@ -60,9 +60,13 @@ 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:
for _item in self.usage:
if _item:
_items.append(_item.to_dict())
_dict['usage'] = _items
return _dict
@classmethod
@@ -82,7 +86,7 @@ class Service(BaseModel):
"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
"usage": [ServiceUsage.from_dict(_item) for _item in obj.get("usage")] if obj.get("usage") is not None else None
})
return _obj

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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