Commit b5e397ab68741bf9df048139867c2d83a90841cd

Authored by Ravi Kumar
1 parent 9b55819b

Test bugs

... ... @@ -41,4 +41,4 @@ from kf_sdk.models.user_details import UserDetails
41 41 from kf_sdk.models.user_type_details import UserTypeDetails
42 42 from kf_sdk.models.validation_error import ValidationError
43 43 from kf_sdk.models.dataset_details import DatasetDetails
44   -from kf_sdk.models.dataset_versions import DatasetVersion
  44 +from kf_sdk.models.dataset_version import DatasetVersion
... ...
This diff could not be displayed because it is too large.
... ... @@ -18,12 +18,12 @@ from typing_extensions import Annotated
18 18
19 19 from pydantic import StrictInt
20 20 from typing import Any
21   -from kappa_users.models.new_session import NewSession
22   -from kappa_users.models.user_details import UserDetails
  21 +from kf_sdk.models.new_session import NewSession
  22 +from kf_sdk.models.user_details import UserDetails
23 23
24   -from kappa_users.api_client import ApiClient, RequestSerialized
25   -from kappa_users.api_response import ApiResponse
26   -from kappa_users.rest import RESTResponseType
  24 +from kf_sdk.api_client import ApiClient, RequestSerialized
  25 +from kf_sdk.api_response import ApiResponse
  26 +from kf_sdk.rest import RESTResponseType
27 27
28 28
29 29 class SessionManagementApi:
... ...
... ... @@ -449,7 +449,7 @@ class ApiClient:
449 449 if klass in self.NATIVE_TYPES_MAPPING:
450 450 klass = self.NATIVE_TYPES_MAPPING[klass]
451 451 else:
452   - klass = getattr(kappa_users.models, klass)
  452 + klass = getattr(kf_sdk.models, klass)
453 453
454 454 if klass in self.PRIMITIVE_TYPES:
455 455 return self.__deserialize_primitive(data, klass)
... ...
... ... @@ -22,4 +22,5 @@ from kf_sdk.models.user_type_details import UserTypeDetails
22 22 from kf_sdk.models.organization_details import OrganizationDetails
23 23 from kf_sdk.models.validation_error import ValidationError
24 24 from kf_sdk.models.dataset_details import DatasetDetails
25   -from kf_sdk.models.dataset_versions import DatasetVersion
  25 +from kf_sdk.models.dataset_version import DatasetVersion
  26 +from kf_sdk.models.location_inner import LocationInner
... ...
  1 +# coding: utf-8
  2 +
  3 +"""
  4 + Kappa-framework data microservices
  5 +
  6 + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
  7 +
  8 + The version of the OpenAPI document: 0.1.0
  9 + Generated by OpenAPI Generator (https://openapi-generator.tech)
  10 +
  11 + Do not edit the class manually.
  12 +""" # noqa: E501
  13 +
  14 +
  15 +from __future__ import annotations
  16 +from inspect import getfullargspec
  17 +import json
  18 +import pprint
  19 +import re # noqa: F401
  20 +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, ValidationError, field_validator
  21 +from typing import Optional
  22 +from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict
  23 +from typing_extensions import Literal, Self
  24 +from pydantic import Field
  25 +
  26 +LOCATIONINNER_ANY_OF_SCHEMAS = ["int", "str"]
  27 +
  28 +class LocationInner(BaseModel):
  29 + """
  30 + LocationInner
  31 + """
  32 +
  33 + # data type: str
  34 + anyof_schema_1_validator: Optional[StrictStr] = None
  35 + # data type: int
  36 + anyof_schema_2_validator: Optional[StrictInt] = None
  37 + if TYPE_CHECKING:
  38 + actual_instance: Optional[Union[int, str]] = None
  39 + else:
  40 + actual_instance: Any = None
  41 + any_of_schemas: Set[str] = { "int", "str" }
  42 +
  43 + model_config = {
  44 + "validate_assignment": True,
  45 + "protected_namespaces": (),
  46 + }
  47 +
  48 + def __init__(self, *args, **kwargs) -> None:
  49 + if args:
  50 + if len(args) > 1:
  51 + raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
  52 + if kwargs:
  53 + raise ValueError("If a position argument is used, keyword arguments cannot be used.")
  54 + super().__init__(actual_instance=args[0])
  55 + else:
  56 + super().__init__(**kwargs)
  57 +
  58 + @field_validator('actual_instance')
  59 + def actual_instance_must_validate_anyof(cls, v):
  60 + instance = LocationInner.model_construct()
  61 + error_messages = []
  62 + # validate data type: str
  63 + try:
  64 + instance.anyof_schema_1_validator = v
  65 + return v
  66 + except (ValidationError, ValueError) as e:
  67 + error_messages.append(str(e))
  68 + # validate data type: int
  69 + try:
  70 + instance.anyof_schema_2_validator = v
  71 + return v
  72 + except (ValidationError, ValueError) as e:
  73 + error_messages.append(str(e))
  74 + if error_messages:
  75 + # no match
  76 + raise ValueError("No match found when setting the actual_instance in LocationInner with anyOf schemas: int, str. Details: " + ", ".join(error_messages))
  77 + else:
  78 + return v
  79 +
  80 + @classmethod
  81 + def from_dict(cls, obj: Dict[str, Any]) -> Self:
  82 + return cls.from_json(json.dumps(obj))
  83 +
  84 + @classmethod
  85 + def from_json(cls, json_str: str) -> Self:
  86 + """Returns the object represented by the json string"""
  87 + instance = cls.model_construct()
  88 + error_messages = []
  89 + # deserialize data into str
  90 + try:
  91 + # validation
  92 + instance.anyof_schema_1_validator = json.loads(json_str)
  93 + # assign value to actual_instance
  94 + instance.actual_instance = instance.anyof_schema_1_validator
  95 + return instance
  96 + except (ValidationError, ValueError) as e:
  97 + error_messages.append(str(e))
  98 + # deserialize data into int
  99 + try:
  100 + # validation
  101 + instance.anyof_schema_2_validator = json.loads(json_str)
  102 + # assign value to actual_instance
  103 + instance.actual_instance = instance.anyof_schema_2_validator
  104 + return instance
  105 + except (ValidationError, ValueError) as e:
  106 + error_messages.append(str(e))
  107 +
  108 + if error_messages:
  109 + # no match
  110 + raise ValueError("No match found when deserializing the JSON string into LocationInner with anyOf schemas: int, str. Details: " + ", ".join(error_messages))
  111 + else:
  112 + return instance
  113 +
  114 + def to_json(self) -> str:
  115 + """Returns the JSON representation of the actual instance"""
  116 + if self.actual_instance is None:
  117 + return "null"
  118 +
  119 + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
  120 + return self.actual_instance.to_json()
  121 + else:
  122 + return json.dumps(self.actual_instance)
  123 +
  124 + def to_dict(self) -> Optional[Union[Dict[str, Any], int, str]]:
  125 + """Returns the dict representation of the actual instance"""
  126 + if self.actual_instance is None:
  127 + return None
  128 +
  129 + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
  130 + return self.actual_instance.to_dict()
  131 + else:
  132 + return self.actual_instance
  133 +
  134 + def to_str(self) -> str:
  135 + """Returns the string representation of the actual instance"""
  136 + return pprint.pformat(self.model_dump())
  137 +
  138 +
... ...
... ... @@ -19,7 +19,7 @@ import json
19 19
20 20 from pydantic import BaseModel, ConfigDict, StrictStr
21 21 from typing import Any, ClassVar, Dict, List
22   -from kappa_users.models.location_inner import LocationInner
  22 +from kf_sdk.models.location_inner import LocationInner
23 23 from typing import Optional, Set
24 24 from typing_extensions import Self
25 25
... ...
  1 +import kf_sdk
  2 +from kf_sdk.rest import ApiException
  3 +from kf_sdk.models import NewSession
  4 +from pprint import pprint
  5 +
  6 +# Defining the host is optional and defaults to http://localhost/user-micro-services/v1
  7 +# See configuration.py for a list of all supported configuration parameters.
  8 +configuration_users = kf_sdk.Configuration(
  9 + host = "https://bigdata.nsu.ru:8460/user-micro-services/v1"
  10 +)
  11 +# The client must configure the authentication and authorization parameters
  12 +# in accordance with the API server security policy.
  13 +# Examples for each auth method are provided below, use the example that
  14 +# satisfies your auth use case.
  15 +
  16 +# Configure Bearer authorization: HTTPBearer
  17 +#configuration = kappa_users.Configuration(
  18 +# access_token = os.environ["BEARER_TOKEN"]
  19 +#)
  20 +
  21 +
  22 +# Enter a context with an instance of the API client
  23 +with kf_sdk.ApiClient(configuration_users) as api_client:
  24 + # Create an instance of the API class
  25 + api_instance = kf_sdk.SessionManagementApi(api_client)
  26 + login_id = "anonymous"
  27 + passwd = "anonymous"
  28 + new_session = NewSession(login_id=login_id,passwd=passwd)
  29 +
  30 + try:
  31 + # New Session
  32 + api_response = api_instance.get_new_session(new_session)
  33 + token = api_response.token
  34 + user_id = api_response.user_id
  35 + user_type_id = api_response.user_type_id
  36 + print("The response of SessionManagementApi->new_session_session_new_post:\n")
  37 + pprint(api_response)
  38 + except ApiException as e:
  39 + print("Exception when calling ExpertManagementApi->new_session_session_new_post: %s\n" % e)
  40 +
  41 +configuration_data = kf_sdk.Configuration(
  42 + host = "https://bigdata.nsu.ru:8460/data-micro-services/v1",
  43 + access_token = token
  44 +)
  45 +
  46 +
  47 +with kf_sdk.ApiClient(configuration_data) as api_client:
  48 + # Create an instance of the API class
  49 + api_instance = kf_sdk.DatasetManagementApi(api_client)
  50 + dataset_id = 581
  51 + dataset_version_no = '1.0.0'
  52 +
  53 + try:
  54 + # Get Dataset Version
  55 + api_response = api_instance.get_dataset_version_datasets_versions_user_id_user_type_id_dataset_id_dataset_version_no_get(user_id, user_type_id, dataset_id, dataset_version_no)
  56 +# api_response = api_instance.get_dataset_version_archive_datasets_versions_archive_user_id_user_type_id_dataset_id_dataset_version_no_get(user_id, user_type_id, dataset_id, dataset_version_no)
  57 +# api_response = api_instance.get_dataset_version_archive_datasets_versions_archive_user_id_user_type_id_dataset_id_dataset_version_no_get_with_http_info(user_id, user_type_id, dataset_id, dataset_version_no)
  58 + # api_response = api_instance.get_dataset_version_archive_datasets_versions_archive_user_id_user_type_id_dataset_id_dataset_version_no_get_without_preload_content(user_id, user_type_id, dataset_id, dataset_version_no)
  59 + pprint(api_response)
  60 + # with open("tmp.zip","wb") as f:
  61 + # f.write(api_response.data)
  62 + except Exception as e:
  63 + print("Exception when calling DatasetManagementApi->get_dataset_version_datasets_versions_user_id_user_type_id_dataset_id_dataset_version_no_get: %s\n" % e)
... ...
Please register or login to post a comment