From 758179c08d98e7bf7f5c63c54039434f0184d9d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20G=C3=B6bel?= Date: Thu, 25 Apr 2024 09:13:00 +0200 Subject: [PATCH] new subtype property --- docs/CalculationRule.md | 37 + docs/CalculationRulesApi.md | 440 ++++++ .../api_client2/api/calculation_rules_api.py | 1382 +++++++++++++++++ eliona/api_client2/models/calculation_rule.py | 130 ++ 4 files changed, 1989 insertions(+) create mode 100644 docs/CalculationRule.md create mode 100644 docs/CalculationRulesApi.md create mode 100644 eliona/api_client2/api/calculation_rules_api.py create mode 100644 eliona/api_client2/models/calculation_rule.py diff --git a/docs/CalculationRule.md b/docs/CalculationRule.md new file mode 100644 index 0000000..ce77791 --- /dev/null +++ b/docs/CalculationRule.md @@ -0,0 +1,37 @@ +# CalculationRule + +Calculation rule to calculate asset attribute data + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | The id of the rule | [optional] [readonly] +**asset_id** | **int** | ID of the corresponding asset | +**subtype** | [**DataSubtype**](DataSubtype.md) | | +**attribute** | **str** | Name of the attribute of the asset type to be calculated | +**virtual** | **bool** | Is the calculation attribute virtual or not | [optional] +**formula** | **str** | calculation rule to calculate the value for the attribute | [optional] +**unit** | **str** | Physical unit of calculated data | [optional] +**filter** | **object** | Filter definition for calculation rule | [optional] + +## Example + +```python +from eliona.api_client2.models.calculation_rule import CalculationRule + +# TODO update the JSON string below +json = "{}" +# create an instance of CalculationRule from a JSON string +calculation_rule_instance = CalculationRule.from_json(json) +# print the JSON string representation of the object +print CalculationRule.to_json() + +# convert the object into a dict +calculation_rule_dict = calculation_rule_instance.to_dict() +# create an instance of CalculationRule from a dict +calculation_rule_form_dict = calculation_rule.from_dict(calculation_rule_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/docs/CalculationRulesApi.md b/docs/CalculationRulesApi.md new file mode 100644 index 0000000..b7adf3e --- /dev/null +++ b/docs/CalculationRulesApi.md @@ -0,0 +1,440 @@ +# eliona.api_client2.CalculationRulesApi + +All URIs are relative to *https://name.eliona.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**delete_calculation_rule_by_id**](CalculationRulesApi.md#delete_calculation_rule_by_id) | **DELETE** /calculation-rules/{calculation-rule-id} | Delete a calculation rule +[**get_calculation_rule_by_id**](CalculationRulesApi.md#get_calculation_rule_by_id) | **GET** /calculation-rules/{calculation-rule-id} | Information about a calculation rules rule +[**get_calculation_rules**](CalculationRulesApi.md#get_calculation_rules) | **GET** /calculation-rules | Information about calculation rules +[**put_calculation_rule**](CalculationRulesApi.md#put_calculation_rule) | **PUT** /calculation-rules | Creates or updates a calculation rule +[**put_calculation_rule_by_id**](CalculationRulesApi.md#put_calculation_rule_by_id) | **PUT** /calculation-rules/{calculation-rule-id} | Update a calculation rule + + +# **delete_calculation_rule_by_id** +> delete_calculation_rule_by_id(calculation_rule_id) + +Delete a calculation rule + +Deletes a calculation rule. + +### Example + +* Api Key Authentication (ApiKeyAuth): +* Bearer (JWT) Authentication (BearerAuth): + +```python +import eliona.api_client2 +from eliona.api_client2.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://name.eliona.io/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = eliona.api_client2.Configuration( + host = "https://name.eliona.io/v2" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure API key authorization: ApiKeyAuth +configuration.api_key['ApiKeyAuth'] = os.environ["API_KEY"] + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['ApiKeyAuth'] = 'Bearer' + +# Configure Bearer authorization (JWT): BearerAuth +configuration = eliona.api_client2.Configuration( + access_token = os.environ["BEARER_TOKEN"] +) + +# Enter a context with an instance of the API client +with eliona.api_client2.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = eliona.api_client2.CalculationRulesApi(api_client) + calculation_rule_id = 4711 # int | The id of the calculation rule + + try: + # Delete a calculation rule + api_instance.delete_calculation_rule_by_id(calculation_rule_id) + except Exception as e: + print("Exception when calling CalculationRulesApi->delete_calculation_rule_by_id: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **calculation_rule_id** | **int**| The id of the calculation rule | + +### Return type + +void (empty response body) + +### Authorization + +[ApiKeyAuth](../README.md#ApiKeyAuth), [BearerAuth](../README.md#BearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**204** | Successfully deleted the calculation rule | - | +**404** | Calculation rule with id not found | - | + +[[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_calculation_rule_by_id** +> CalculationRule get_calculation_rule_by_id(calculation_rule_id) + +Information about a calculation rules rule + +Gets information about a calculation rule. + +### Example + +* Api Key Authentication (ApiKeyAuth): +* Bearer (JWT) Authentication (BearerAuth): + +```python +import eliona.api_client2 +from eliona.api_client2.models.calculation_rule import CalculationRule +from eliona.api_client2.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://name.eliona.io/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = eliona.api_client2.Configuration( + host = "https://name.eliona.io/v2" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure API key authorization: ApiKeyAuth +configuration.api_key['ApiKeyAuth'] = os.environ["API_KEY"] + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['ApiKeyAuth'] = 'Bearer' + +# Configure Bearer authorization (JWT): BearerAuth +configuration = eliona.api_client2.Configuration( + access_token = os.environ["BEARER_TOKEN"] +) + +# Enter a context with an instance of the API client +with eliona.api_client2.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = eliona.api_client2.CalculationRulesApi(api_client) + calculation_rule_id = 4711 # int | The id of the calculation rule + + try: + # Information about a calculation rules rule + api_response = api_instance.get_calculation_rule_by_id(calculation_rule_id) + print("The response of CalculationRulesApi->get_calculation_rule_by_id:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling CalculationRulesApi->get_calculation_rule_by_id: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **calculation_rule_id** | **int**| The id of the calculation rule | + +### Return type + +[**CalculationRule**](CalculationRule.md) + +### Authorization + +[ApiKeyAuth](../README.md#ApiKeyAuth), [BearerAuth](../README.md#BearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successfully returned ancalculation rule | - | +**404** | Calculation rule with id not found | - | + +[[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_calculation_rules** +> List[CalculationRule] get_calculation_rules(calculation_rule_ids=calculation_rule_ids) + +Information about calculation rules + +Gets information about calculation rules. + +### Example + +* Api Key Authentication (ApiKeyAuth): +* Bearer (JWT) Authentication (BearerAuth): + +```python +import eliona.api_client2 +from eliona.api_client2.models.calculation_rule import CalculationRule +from eliona.api_client2.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://name.eliona.io/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = eliona.api_client2.Configuration( + host = "https://name.eliona.io/v2" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure API key authorization: ApiKeyAuth +configuration.api_key['ApiKeyAuth'] = os.environ["API_KEY"] + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['ApiKeyAuth'] = 'Bearer' + +# Configure Bearer authorization (JWT): BearerAuth +configuration = eliona.api_client2.Configuration( + access_token = os.environ["BEARER_TOKEN"] +) + +# Enter a context with an instance of the API client +with eliona.api_client2.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = eliona.api_client2.CalculationRulesApi(api_client) + calculation_rule_ids = [56] # List[int] | List of calculation rule ids for filtering (optional) + + try: + # Information about calculation rules + api_response = api_instance.get_calculation_rules(calculation_rule_ids=calculation_rule_ids) + print("The response of CalculationRulesApi->get_calculation_rules:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling CalculationRulesApi->get_calculation_rules: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **calculation_rule_ids** | [**List[int]**](int.md)| List of calculation rule ids for filtering | [optional] + +### Return type + +[**List[CalculationRule]**](CalculationRule.md) + +### Authorization + +[ApiKeyAuth](../README.md#ApiKeyAuth), [BearerAuth](../README.md#BearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successfully returned a list of calculation rules | - | + +[[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) + +# **put_calculation_rule** +> CalculationRule put_calculation_rule(calculation_rule) + +Creates or updates a calculation rule + +Creates a new or updates an existing calculation rule. + +### Example + +* Api Key Authentication (ApiKeyAuth): +* Bearer (JWT) Authentication (BearerAuth): + +```python +import eliona.api_client2 +from eliona.api_client2.models.calculation_rule import CalculationRule +from eliona.api_client2.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://name.eliona.io/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = eliona.api_client2.Configuration( + host = "https://name.eliona.io/v2" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure API key authorization: ApiKeyAuth +configuration.api_key['ApiKeyAuth'] = os.environ["API_KEY"] + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['ApiKeyAuth'] = 'Bearer' + +# Configure Bearer authorization (JWT): BearerAuth +configuration = eliona.api_client2.Configuration( + access_token = os.environ["BEARER_TOKEN"] +) + +# Enter a context with an instance of the API client +with eliona.api_client2.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = eliona.api_client2.CalculationRulesApi(api_client) + calculation_rule = eliona.api_client2.CalculationRule() # CalculationRule | + + try: + # Creates or updates a calculation rule + api_response = api_instance.put_calculation_rule(calculation_rule) + print("The response of CalculationRulesApi->put_calculation_rule:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling CalculationRulesApi->put_calculation_rule: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **calculation_rule** | [**CalculationRule**](CalculationRule.md)| | + +### Return type + +[**CalculationRule**](CalculationRule.md) + +### Authorization + +[ApiKeyAuth](../README.md#ApiKeyAuth), [BearerAuth](../README.md#BearerAuth) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successfully created or updated a calculation rule | - | + +[[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) + +# **put_calculation_rule_by_id** +> CalculationRule put_calculation_rule_by_id(calculation_rule_id, calculation_rule) + +Update a calculation rule + +Update a calculation rule. + +### Example + +* Api Key Authentication (ApiKeyAuth): +* Bearer (JWT) Authentication (BearerAuth): + +```python +import eliona.api_client2 +from eliona.api_client2.models.calculation_rule import CalculationRule +from eliona.api_client2.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://name.eliona.io/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = eliona.api_client2.Configuration( + host = "https://name.eliona.io/v2" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure API key authorization: ApiKeyAuth +configuration.api_key['ApiKeyAuth'] = os.environ["API_KEY"] + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['ApiKeyAuth'] = 'Bearer' + +# Configure Bearer authorization (JWT): BearerAuth +configuration = eliona.api_client2.Configuration( + access_token = os.environ["BEARER_TOKEN"] +) + +# Enter a context with an instance of the API client +with eliona.api_client2.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = eliona.api_client2.CalculationRulesApi(api_client) + calculation_rule_id = 4711 # int | The id of the calculation rule + calculation_rule = eliona.api_client2.CalculationRule() # CalculationRule | + + try: + # Update a calculation rule + api_response = api_instance.put_calculation_rule_by_id(calculation_rule_id, calculation_rule) + print("The response of CalculationRulesApi->put_calculation_rule_by_id:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling CalculationRulesApi->put_calculation_rule_by_id: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **calculation_rule_id** | **int**| The id of the calculation rule | + **calculation_rule** | [**CalculationRule**](CalculationRule.md)| | + +### Return type + +[**CalculationRule**](CalculationRule.md) + +### Authorization + +[ApiKeyAuth](../README.md#ApiKeyAuth), [BearerAuth](../README.md#BearerAuth) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successfully updated an existing calculation rule | - | +**404** | Calculation rule with id not found | - | + +[[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/eliona/api_client2/api/calculation_rules_api.py b/eliona/api_client2/api/calculation_rules_api.py new file mode 100644 index 0000000..483c9d2 --- /dev/null +++ b/eliona/api_client2/api/calculation_rules_api.py @@ -0,0 +1,1382 @@ +# coding: utf-8 + +""" + Eliona REST API + + The Eliona REST API enables unified access to the resources and data of an Eliona environment. + + The version of the OpenAPI document: 2.6.11 + Contact: hello@eliona.io + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from pydantic import Field, StrictInt +from typing import List, Optional +from typing_extensions import Annotated +from eliona.api_client2.models.calculation_rule import CalculationRule + +from eliona.api_client2.api_client import ApiClient, RequestSerialized +from eliona.api_client2.api_response import ApiResponse +from eliona.api_client2.rest import RESTResponseType + + +class CalculationRulesApi: + """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_call + def delete_calculation_rule_by_id( + self, + calculation_rule_id: Annotated[StrictInt, Field(description="The id of the calculation rule")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """Delete a calculation rule + + Deletes a calculation rule. + + :param calculation_rule_id: The id of the calculation rule (required) + :type calculation_rule_id: int + :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. + :type _request_timeout: int, tuple(int, int), optional + :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 + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_calculation_rule_by_id_serialize( + calculation_rule_id=calculation_rule_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + '404': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def delete_calculation_rule_by_id_with_http_info( + self, + calculation_rule_id: Annotated[StrictInt, Field(description="The id of the calculation rule")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """Delete a calculation rule + + Deletes a calculation rule. + + :param calculation_rule_id: The id of the calculation rule (required) + :type calculation_rule_id: int + :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. + :type _request_timeout: int, tuple(int, int), optional + :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 + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_calculation_rule_by_id_serialize( + calculation_rule_id=calculation_rule_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + '404': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def delete_calculation_rule_by_id_without_preload_content( + self, + calculation_rule_id: Annotated[StrictInt, Field(description="The id of the calculation rule")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Delete a calculation rule + + Deletes a calculation rule. + + :param calculation_rule_id: The id of the calculation rule (required) + :type calculation_rule_id: int + :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. + :type _request_timeout: int, tuple(int, int), optional + :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 + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._delete_calculation_rule_by_id_serialize( + calculation_rule_id=calculation_rule_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + '404': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _delete_calculation_rule_by_id_serialize( + self, + calculation_rule_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if calculation_rule_id is not None: + _path_params['calculation-rule-id'] = calculation_rule_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + + + # authentication setting + _auth_settings: List[str] = [ + 'ApiKeyAuth', + 'BearerAuth' + ] + + return self.api_client.param_serialize( + method='DELETE', + resource_path='/calculation-rules/{calculation-rule-id}', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def get_calculation_rule_by_id( + self, + calculation_rule_id: Annotated[StrictInt, Field(description="The id of the calculation rule")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> CalculationRule: + """Information about a calculation rules rule + + Gets information about a calculation rule. + + :param calculation_rule_id: The id of the calculation rule (required) + :type calculation_rule_id: int + :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. + :type _request_timeout: int, tuple(int, int), optional + :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 + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_calculation_rule_by_id_serialize( + calculation_rule_id=calculation_rule_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "CalculationRule", + '404': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def get_calculation_rule_by_id_with_http_info( + self, + calculation_rule_id: Annotated[StrictInt, Field(description="The id of the calculation rule")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[CalculationRule]: + """Information about a calculation rules rule + + Gets information about a calculation rule. + + :param calculation_rule_id: The id of the calculation rule (required) + :type calculation_rule_id: int + :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. + :type _request_timeout: int, tuple(int, int), optional + :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 + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_calculation_rule_by_id_serialize( + calculation_rule_id=calculation_rule_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "CalculationRule", + '404': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def get_calculation_rule_by_id_without_preload_content( + self, + calculation_rule_id: Annotated[StrictInt, Field(description="The id of the calculation rule")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Information about a calculation rules rule + + Gets information about a calculation rule. + + :param calculation_rule_id: The id of the calculation rule (required) + :type calculation_rule_id: int + :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. + :type _request_timeout: int, tuple(int, int), optional + :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 + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_calculation_rule_by_id_serialize( + calculation_rule_id=calculation_rule_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "CalculationRule", + '404': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _get_calculation_rule_by_id_serialize( + self, + calculation_rule_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if calculation_rule_id is not None: + _path_params['calculation-rule-id'] = calculation_rule_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + 'ApiKeyAuth', + 'BearerAuth' + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/calculation-rules/{calculation-rule-id}', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def get_calculation_rules( + self, + calculation_rule_ids: Annotated[Optional[List[StrictInt]], Field(description="List of calculation rule ids for filtering")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> List[CalculationRule]: + """Information about calculation rules + + Gets information about calculation rules. + + :param calculation_rule_ids: List of calculation rule ids for filtering + :type calculation_rule_ids: List[int] + :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. + :type _request_timeout: int, tuple(int, int), optional + :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 + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_calculation_rules_serialize( + calculation_rule_ids=calculation_rule_ids, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "List[CalculationRule]", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def get_calculation_rules_with_http_info( + self, + calculation_rule_ids: Annotated[Optional[List[StrictInt]], Field(description="List of calculation rule ids for filtering")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[List[CalculationRule]]: + """Information about calculation rules + + Gets information about calculation rules. + + :param calculation_rule_ids: List of calculation rule ids for filtering + :type calculation_rule_ids: List[int] + :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. + :type _request_timeout: int, tuple(int, int), optional + :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 + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_calculation_rules_serialize( + calculation_rule_ids=calculation_rule_ids, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "List[CalculationRule]", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def get_calculation_rules_without_preload_content( + self, + calculation_rule_ids: Annotated[Optional[List[StrictInt]], Field(description="List of calculation rule ids for filtering")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Information about calculation rules + + Gets information about calculation rules. + + :param calculation_rule_ids: List of calculation rule ids for filtering + :type calculation_rule_ids: List[int] + :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. + :type _request_timeout: int, tuple(int, int), optional + :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 + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_calculation_rules_serialize( + calculation_rule_ids=calculation_rule_ids, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "List[CalculationRule]", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _get_calculation_rules_serialize( + self, + calculation_rule_ids, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + 'calculationRuleIds': 'csv', + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if calculation_rule_ids is not None: + + _query_params.append(('calculationRuleIds', calculation_rule_ids)) + + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + 'ApiKeyAuth', + 'BearerAuth' + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/calculation-rules', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def put_calculation_rule( + self, + calculation_rule: Optional[CalculationRule], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> CalculationRule: + """Creates or updates a calculation rule + + Creates a new or updates an existing calculation rule. + + :param calculation_rule: (required) + :type calculation_rule: CalculationRule + :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. + :type _request_timeout: int, tuple(int, int), optional + :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 + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._put_calculation_rule_serialize( + calculation_rule=calculation_rule, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "CalculationRule", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def put_calculation_rule_with_http_info( + self, + calculation_rule: Optional[CalculationRule], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[CalculationRule]: + """Creates or updates a calculation rule + + Creates a new or updates an existing calculation rule. + + :param calculation_rule: (required) + :type calculation_rule: CalculationRule + :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. + :type _request_timeout: int, tuple(int, int), optional + :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 + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._put_calculation_rule_serialize( + calculation_rule=calculation_rule, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "CalculationRule", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def put_calculation_rule_without_preload_content( + self, + calculation_rule: Optional[CalculationRule], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Creates or updates a calculation rule + + Creates a new or updates an existing calculation rule. + + :param calculation_rule: (required) + :type calculation_rule: CalculationRule + :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. + :type _request_timeout: int, tuple(int, int), optional + :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 + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._put_calculation_rule_serialize( + calculation_rule=calculation_rule, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "CalculationRule", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _put_calculation_rule_serialize( + self, + calculation_rule, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if calculation_rule is not None: + _body_params = calculation_rule + + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + 'ApiKeyAuth', + 'BearerAuth' + ] + + return self.api_client.param_serialize( + method='PUT', + resource_path='/calculation-rules', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def put_calculation_rule_by_id( + self, + calculation_rule_id: Annotated[StrictInt, Field(description="The id of the calculation rule")], + calculation_rule: Optional[CalculationRule], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> CalculationRule: + """Update a calculation rule + + Update a calculation rule. + + :param calculation_rule_id: The id of the calculation rule (required) + :type calculation_rule_id: int + :param calculation_rule: (required) + :type calculation_rule: CalculationRule + :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. + :type _request_timeout: int, tuple(int, int), optional + :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 + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._put_calculation_rule_by_id_serialize( + calculation_rule_id=calculation_rule_id, + calculation_rule=calculation_rule, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "CalculationRule", + '404': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def put_calculation_rule_by_id_with_http_info( + self, + calculation_rule_id: Annotated[StrictInt, Field(description="The id of the calculation rule")], + calculation_rule: Optional[CalculationRule], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[CalculationRule]: + """Update a calculation rule + + Update a calculation rule. + + :param calculation_rule_id: The id of the calculation rule (required) + :type calculation_rule_id: int + :param calculation_rule: (required) + :type calculation_rule: CalculationRule + :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. + :type _request_timeout: int, tuple(int, int), optional + :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 + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._put_calculation_rule_by_id_serialize( + calculation_rule_id=calculation_rule_id, + calculation_rule=calculation_rule, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "CalculationRule", + '404': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def put_calculation_rule_by_id_without_preload_content( + self, + calculation_rule_id: Annotated[StrictInt, Field(description="The id of the calculation rule")], + calculation_rule: Optional[CalculationRule], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Update a calculation rule + + Update a calculation rule. + + :param calculation_rule_id: The id of the calculation rule (required) + :type calculation_rule_id: int + :param calculation_rule: (required) + :type calculation_rule: CalculationRule + :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. + :type _request_timeout: int, tuple(int, int), optional + :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 + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._put_calculation_rule_by_id_serialize( + calculation_rule_id=calculation_rule_id, + calculation_rule=calculation_rule, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "CalculationRule", + '404': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _put_calculation_rule_by_id_serialize( + self, + calculation_rule_id, + calculation_rule, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if calculation_rule_id is not None: + _path_params['calculation-rule-id'] = calculation_rule_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if calculation_rule is not None: + _body_params = calculation_rule + + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + 'ApiKeyAuth', + 'BearerAuth' + ] + + return self.api_client.param_serialize( + method='PUT', + resource_path='/calculation-rules/{calculation-rule-id}', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + diff --git a/eliona/api_client2/models/calculation_rule.py b/eliona/api_client2/models/calculation_rule.py new file mode 100644 index 0000000..b8236eb --- /dev/null +++ b/eliona/api_client2/models/calculation_rule.py @@ -0,0 +1,130 @@ +# coding: utf-8 + +""" + Eliona REST API + + The Eliona REST API enables unified access to the resources and data of an Eliona environment. + + The version of the OpenAPI document: 2.6.11 + Contact: hello@eliona.io + 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, StrictBool, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from eliona.api_client2.models.data_subtype import DataSubtype +from typing import Optional, Set +from typing_extensions import Self + +class CalculationRule(BaseModel): + """ + Calculation rule to calculate asset attribute data + """ # noqa: E501 + id: Optional[StrictInt] = Field(default=None, description="The id of the rule") + asset_id: StrictInt = Field(description="ID of the corresponding asset", alias="assetId") + subtype: DataSubtype + attribute: StrictStr = Field(description="Name of the attribute of the asset type to be calculated") + virtual: Optional[StrictBool] = Field(default=None, description="Is the calculation attribute virtual or not") + formula: Optional[StrictStr] = Field(default=None, description="calculation rule to calculate the value for the attribute") + unit: Optional[StrictStr] = Field(default=None, description="Physical unit of calculated data") + filter: Optional[Dict[str, Any]] = Field(default=None, description="Filter definition for calculation rule") + __properties: ClassVar[List[str]] = ["id", "assetId", "subtype", "attribute", "virtual", "formula", "unit", "filter"] + + model_config = { + "populate_by_name": True, + "validate_assignment": True, + "protected_namespaces": (), + } + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CalculationRule from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * OpenAPI `readOnly` fields are excluded. + """ + excluded_fields: Set[str] = set([ + "id", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # set to None if id (nullable) is None + # and model_fields_set contains the field + if self.id is None and "id" in self.model_fields_set: + _dict['id'] = None + + # set to None if virtual (nullable) is None + # and model_fields_set contains the field + if self.virtual is None and "virtual" in self.model_fields_set: + _dict['virtual'] = None + + # set to None if formula (nullable) is None + # and model_fields_set contains the field + if self.formula is None and "formula" in self.model_fields_set: + _dict['formula'] = None + + # set to None if unit (nullable) is None + # and model_fields_set contains the field + if self.unit is None and "unit" in self.model_fields_set: + _dict['unit'] = None + + # set to None if filter (nullable) is None + # and model_fields_set contains the field + if self.filter is None and "filter" in self.model_fields_set: + _dict['filter'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CalculationRule from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "assetId": obj.get("assetId"), + "subtype": obj.get("subtype"), + "attribute": obj.get("attribute"), + "virtual": obj.get("virtual"), + "formula": obj.get("formula"), + "unit": obj.get("unit"), + "filter": obj.get("filter") + }) + return _obj + +