diff --git a/.sdk-version b/.sdk-version index 7c47abe..df46356 100644 --- a/.sdk-version +++ b/.sdk-version @@ -1 +1 @@ -v3.96.4 +v3.97.0 diff --git a/README.md b/README.md index d605fda..3c96bf7 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,7 @@ Class | Method | HTTP request | Description *AnalysesCoreApi* | [**upload_file**](docs/AnalysesCoreApi.md#upload_file) | **POST** /v2/upload | Upload File *AnalysesCoreApi* | [**v3_get_analysis_strings**](docs/AnalysesCoreApi.md#v3_get_analysis_strings) | **GET** /v3/analyses/{analysis_id}/functions/strings | List strings for an analysis. *AnalysesCoreApi* | [**v3_get_analysis_strings_status**](docs/AnalysesCoreApi.md#v3_get_analysis_strings_status) | **GET** /v3/analyses/{analysis_id}/functions/strings/status | Get the string-extraction status for an analysis. +*AnalysesCoreApi* | [**v3_list_example_analyses**](docs/AnalysesCoreApi.md#v3_list_example_analyses) | **GET** /v3/analyses/examples | List example analyses *AnalysesResultsMetadataApi* | [**get_analysis_functions_paginated**](docs/AnalysesResultsMetadataApi.md#get_analysis_functions_paginated) | **GET** /v2/analyses/{analysis_id}/functions | Get functions from analysis *AnalysesResultsMetadataApi* | [**get_capabilities**](docs/AnalysesResultsMetadataApi.md#get_capabilities) | **GET** /v2/analyses/{analysis_id}/capabilities | Gets the capabilities from the analysis *AnalysesResultsMetadataApi* | [**get_functions_list**](docs/AnalysesResultsMetadataApi.md#get_functions_list) | **GET** /v2/analyses/{analysis_id}/functions/list | Gets functions from analysis @@ -444,6 +445,7 @@ Class | Method | HTTP request | Description - [EventTOOLCALLSTART](docs/EventTOOLCALLSTART.md) - [EventTOOLCONFIRMATIONREQUIRED](docs/EventTOOLCONFIRMATIONREQUIRED.md) - [EventWarning](docs/EventWarning.md) + - [Example](docs/Example.md) - [ExportModel](docs/ExportModel.md) - [ExternalResponse](docs/ExternalResponse.md) - [ExtractedURL](docs/ExtractedURL.md) @@ -520,6 +522,7 @@ Class | Method | HTTP request | Description - [ListAnalysisStringsOutputBody](docs/ListAnalysisStringsOutputBody.md) - [ListCollectionResults](docs/ListCollectionResults.md) - [ListCollectionsOutputBody](docs/ListCollectionsOutputBody.md) + - [ListExampleAnalysesOutputBody](docs/ListExampleAnalysesOutputBody.md) - [ListFunctionStringsOutputBody](docs/ListFunctionStringsOutputBody.md) - [ListFunctionsDataTypesOutputBody](docs/ListFunctionsDataTypesOutputBody.md) - [ListTeamsOutputBody](docs/ListTeamsOutputBody.md) diff --git a/docs/AnalysesCoreApi.md b/docs/AnalysesCoreApi.md index cde2a15..42f114d 100644 --- a/docs/AnalysesCoreApi.md +++ b/docs/AnalysesCoreApi.md @@ -29,6 +29,7 @@ Method | HTTP request | Description [**upload_file**](AnalysesCoreApi.md#upload_file) | **POST** /v2/upload | Upload File [**v3_get_analysis_strings**](AnalysesCoreApi.md#v3_get_analysis_strings) | **GET** /v3/analyses/{analysis_id}/functions/strings | List strings for an analysis. [**v3_get_analysis_strings_status**](AnalysesCoreApi.md#v3_get_analysis_strings_status) | **GET** /v3/analyses/{analysis_id}/functions/strings/status | Get the string-extraction status for an analysis. +[**v3_list_example_analyses**](AnalysesCoreApi.md#v3_list_example_analyses) | **GET** /v3/analyses/examples | List example analyses # **add_user_string_to_analysis** @@ -2175,3 +2176,79 @@ Name | Type | Description | Notes [[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) +# **v3_list_example_analyses** +> ListExampleAnalysesOutputBody v3_list_example_analyses() + +List example analyses + +Returns the curated example Analyses. + +### Example + +* Api Key Authentication (APIKey): + +```python +import revengai +from revengai.models.list_example_analyses_output_body import ListExampleAnalysesOutputBody +from revengai.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://api.reveng.ai +# See configuration.py for a list of all supported configuration parameters. +configuration = revengai.Configuration( + host = "https://api.reveng.ai" +) + +# 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: APIKey +configuration.api_key['APIKey'] = os.environ["API_KEY"] + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['APIKey'] = 'Bearer' + +# Enter a context with an instance of the API client +with revengai.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = revengai.AnalysesCoreApi(api_client) + + try: + # List example analyses + api_response = api_instance.v3_list_example_analyses() + print("The response of AnalysesCoreApi->v3_list_example_analyses:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling AnalysesCoreApi->v3_list_example_analyses: %s\n" % e) +``` + + + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**ListExampleAnalysesOutputBody**](ListExampleAnalysesOutputBody.md) + +### Authorization + +[APIKey](../README.md#APIKey) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | OK | - | +**0** | Error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/docs/Example.md b/docs/Example.md new file mode 100644 index 0000000..a71d9a6 --- /dev/null +++ b/docs/Example.md @@ -0,0 +1,40 @@ +# Example + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**analysis_id** | **int** | Analysis ID | +**analysis_scope** | **str** | Scope of the analysis (always PUBLIC for examples) | +**binary_id** | **int** | Binary ID | +**binary_name** | **str** | Binary filename | +**binary_size** | **int** | Binary size in bytes | +**creation** | **datetime** | When the analysis was created | +**is_owner** | **bool** | True when the caller owns the analysis | +**model_id** | **int** | Model ID | +**sha_256_hash** | **str** | SHA-256 hash of the binary | +**status** | **str** | Analysis status | +**tags** | **List[str]** | Tags associated with this binary | +**username** | **str** | Username of the analysis owner | + +## Example + +```python +from revengai.models.example import Example + +# TODO update the JSON string below +json = "{}" +# create an instance of Example from a JSON string +example_instance = Example.from_json(json) +# print the JSON string representation of the object +print(Example.to_json()) + +# convert the object into a dict +example_dict = example_instance.to_dict() +# create an instance of Example from a dict +example_from_dict = Example.from_dict(example_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/ListExampleAnalysesOutputBody.md b/docs/ListExampleAnalysesOutputBody.md new file mode 100644 index 0000000..81247b7 --- /dev/null +++ b/docs/ListExampleAnalysesOutputBody.md @@ -0,0 +1,29 @@ +# ListExampleAnalysesOutputBody + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**analyses** | [**List[Example]**](Example.md) | List of example analyses | + +## Example + +```python +from revengai.models.list_example_analyses_output_body import ListExampleAnalysesOutputBody + +# TODO update the JSON string below +json = "{}" +# create an instance of ListExampleAnalysesOutputBody from a JSON string +list_example_analyses_output_body_instance = ListExampleAnalysesOutputBody.from_json(json) +# print the JSON string representation of the object +print(ListExampleAnalysesOutputBody.to_json()) + +# convert the object into a dict +list_example_analyses_output_body_dict = list_example_analyses_output_body_instance.to_dict() +# create an instance of ListExampleAnalysesOutputBody from a dict +list_example_analyses_output_body_from_dict = ListExampleAnalysesOutputBody.from_dict(list_example_analyses_output_body_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/revengai/__init__.py b/revengai/__init__.py index 1dce145..0a80509 100644 --- a/revengai/__init__.py +++ b/revengai/__init__.py @@ -13,7 +13,7 @@ """ # noqa: E501 -__version__ = "v3.96.4" +__version__ = "v3.97.0" # Define package exports __all__ = [ @@ -290,6 +290,7 @@ "EventTOOLCALLSTART", "EventTOOLCONFIRMATIONREQUIRED", "EventWarning", + "Example", "ExportModel", "ExternalResponse", "ExtractedURL", @@ -366,6 +367,7 @@ "ListAnalysisStringsOutputBody", "ListCollectionResults", "ListCollectionsOutputBody", + "ListExampleAnalysesOutputBody", "ListFunctionStringsOutputBody", "ListFunctionsDataTypesOutputBody", "ListTeamsOutputBody", @@ -818,6 +820,7 @@ from revengai.models.event_toolcallstart import EventTOOLCALLSTART as EventTOOLCALLSTART from revengai.models.event_toolconfirmationrequired import EventTOOLCONFIRMATIONREQUIRED as EventTOOLCONFIRMATIONREQUIRED from revengai.models.event_warning import EventWarning as EventWarning +from revengai.models.example import Example as Example from revengai.models.export_model import ExportModel as ExportModel from revengai.models.external_response import ExternalResponse as ExternalResponse from revengai.models.extracted_url import ExtractedURL as ExtractedURL @@ -894,6 +897,7 @@ from revengai.models.list_analysis_strings_output_body import ListAnalysisStringsOutputBody as ListAnalysisStringsOutputBody from revengai.models.list_collection_results import ListCollectionResults as ListCollectionResults from revengai.models.list_collections_output_body import ListCollectionsOutputBody as ListCollectionsOutputBody +from revengai.models.list_example_analyses_output_body import ListExampleAnalysesOutputBody as ListExampleAnalysesOutputBody from revengai.models.list_function_strings_output_body import ListFunctionStringsOutputBody as ListFunctionStringsOutputBody from revengai.models.list_functions_data_types_output_body import ListFunctionsDataTypesOutputBody as ListFunctionsDataTypesOutputBody from revengai.models.list_teams_output_body import ListTeamsOutputBody as ListTeamsOutputBody diff --git a/revengai/api/analyses_core_api.py b/revengai/api/analyses_core_api.py index 361d7fe..7a91334 100644 --- a/revengai/api/analyses_core_api.py +++ b/revengai/api/analyses_core_api.py @@ -45,6 +45,7 @@ from revengai.models.get_matches_status_output_body import GetMatchesStatusOutputBody from revengai.models.insert_analysis_log_request import InsertAnalysisLogRequest from revengai.models.list_analysis_strings_output_body import ListAnalysisStringsOutputBody +from revengai.models.list_example_analyses_output_body import ListExampleAnalysesOutputBody from revengai.models.model_name import ModelName from revengai.models.order import Order from revengai.models.put_analysis_strings_request import PutAnalysisStringsRequest @@ -7376,3 +7377,249 @@ def _v3_get_analysis_strings_status_serialize( ) + + + @validate_call + def v3_list_example_analyses( + self, + _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, + ) -> ListExampleAnalysesOutputBody: + """List example analyses + + Returns the curated example Analyses. + + :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._v3_list_example_analyses_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ListExampleAnalysesOutputBody", + } + 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 v3_list_example_analyses_with_http_info( + self, + _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[ListExampleAnalysesOutputBody]: + """List example analyses + + Returns the curated example Analyses. + + :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._v3_list_example_analyses_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ListExampleAnalysesOutputBody", + } + 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 v3_list_example_analyses_without_preload_content( + self, + _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: + """List example analyses + + Returns the curated example Analyses. + + :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._v3_list_example_analyses_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ListExampleAnalysesOutputBody", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _v3_list_example_analyses_serialize( + self, + _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, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _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 + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + 'APIKey' + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/v3/analyses/examples', + 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/revengai/api_client.py b/revengai/api_client.py index f9c956c..0227034 100644 --- a/revengai/api_client.py +++ b/revengai/api_client.py @@ -90,7 +90,7 @@ def __init__( self.default_headers[header_name] = header_value self.cookie = cookie # Set default User-Agent. - self.user_agent = 'OpenAPI-Generator/v3.96.4/python' + self.user_agent = 'OpenAPI-Generator/v3.97.0/python' self.client_side_validation = configuration.client_side_validation def __enter__(self): diff --git a/revengai/configuration.py b/revengai/configuration.py index 68951ed..528cbdf 100644 --- a/revengai/configuration.py +++ b/revengai/configuration.py @@ -533,8 +533,8 @@ def to_debug_report(self) -> str: return "Python SDK Debug Report:\n"\ "OS: {env}\n"\ "Python Version: {pyversion}\n"\ - "Version of the API: v3.96.4\n"\ - "SDK Package Version: v3.96.4".\ + "Version of the API: v3.97.0\n"\ + "SDK Package Version: v3.97.0".\ format(env=sys.platform, pyversion=sys.version) def get_host_settings(self) -> List[HostSetting]: diff --git a/revengai/models/__init__.py b/revengai/models/__init__.py index 542582b..8181418 100644 --- a/revengai/models/__init__.py +++ b/revengai/models/__init__.py @@ -255,6 +255,7 @@ from revengai.models.event_toolcallstart import EventTOOLCALLSTART from revengai.models.event_toolconfirmationrequired import EventTOOLCONFIRMATIONREQUIRED from revengai.models.event_warning import EventWarning +from revengai.models.example import Example from revengai.models.export_model import ExportModel from revengai.models.external_response import ExternalResponse from revengai.models.extracted_url import ExtractedURL @@ -331,6 +332,7 @@ from revengai.models.list_analysis_strings_output_body import ListAnalysisStringsOutputBody from revengai.models.list_collection_results import ListCollectionResults from revengai.models.list_collections_output_body import ListCollectionsOutputBody +from revengai.models.list_example_analyses_output_body import ListExampleAnalysesOutputBody from revengai.models.list_function_strings_output_body import ListFunctionStringsOutputBody from revengai.models.list_functions_data_types_output_body import ListFunctionsDataTypesOutputBody from revengai.models.list_teams_output_body import ListTeamsOutputBody diff --git a/revengai/models/example.py b/revengai/models/example.py new file mode 100644 index 0000000..f2e9b82 --- /dev/null +++ b/revengai/models/example.py @@ -0,0 +1,134 @@ +# coding: utf-8 + +""" + RevEng.AI API + + RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + + 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 datetime import datetime +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class Example(BaseModel): + """ + Example + """ # noqa: E501 + analysis_id: StrictInt = Field(description="Analysis ID") + analysis_scope: StrictStr = Field(description="Scope of the analysis (always PUBLIC for examples)") + binary_id: StrictInt = Field(description="Binary ID") + binary_name: StrictStr = Field(description="Binary filename") + binary_size: StrictInt = Field(description="Binary size in bytes") + creation: datetime = Field(description="When the analysis was created") + is_owner: StrictBool = Field(description="True when the caller owns the analysis") + model_id: StrictInt = Field(description="Model ID") + sha_256_hash: StrictStr = Field(description="SHA-256 hash of the binary") + status: StrictStr = Field(description="Analysis status") + tags: Optional[List[StrictStr]] = Field(description="Tags associated with this binary") + username: StrictStr = Field(description="Username of the analysis owner") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["analysis_id", "analysis_scope", "binary_id", "binary_name", "binary_size", "creation", "is_owner", "model_id", "sha_256_hash", "status", "tags", "username"] + + @field_validator('analysis_scope') + def analysis_scope_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['PUBLIC', 'unknown_default_open_api']): + raise ValueError("must be one of enum values ('PUBLIC', 'unknown_default_open_api')") + return value + + model_config = ConfigDict( + 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 Example 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. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + # set to None if tags (nullable) is None + # and model_fields_set contains the field + if self.tags is None and "tags" in self.model_fields_set: + _dict['tags'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Example from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "analysis_id": obj.get("analysis_id"), + "analysis_scope": obj.get("analysis_scope"), + "binary_id": obj.get("binary_id"), + "binary_name": obj.get("binary_name"), + "binary_size": obj.get("binary_size"), + "creation": obj.get("creation"), + "is_owner": obj.get("is_owner"), + "model_id": obj.get("model_id"), + "sha_256_hash": obj.get("sha_256_hash"), + "status": obj.get("status"), + "tags": obj.get("tags"), + "username": obj.get("username") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/revengai/models/list_example_analyses_output_body.py b/revengai/models/list_example_analyses_output_body.py new file mode 100644 index 0000000..e910dce --- /dev/null +++ b/revengai/models/list_example_analyses_output_body.py @@ -0,0 +1,112 @@ +# coding: utf-8 + +""" + RevEng.AI API + + RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + + 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, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from revengai.models.example import Example +from typing import Optional, Set +from typing_extensions import Self + +class ListExampleAnalysesOutputBody(BaseModel): + """ + ListExampleAnalysesOutputBody + """ # noqa: E501 + analyses: Optional[List[Example]] = Field(description="List of example analyses") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["analyses"] + + model_config = ConfigDict( + 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 ListExampleAnalysesOutputBody 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. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in analyses (list) + _items = [] + if self.analyses: + for _item_analyses in self.analyses: + if _item_analyses: + _items.append(_item_analyses.to_dict()) + _dict['analyses'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + # set to None if analyses (nullable) is None + # and model_fields_set contains the field + if self.analyses is None and "analyses" in self.model_fields_set: + _dict['analyses'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ListExampleAnalysesOutputBody from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "analyses": [Example.from_dict(_item) for _item in obj["analyses"]] if obj.get("analyses") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + +