From 2c7b5a2779171ab78311e512440d31a96ab8ced5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 16 Dec 2024 00:11:30 +0000 Subject: [PATCH] Auto-update SDK on 2024-12-16 --- .openapi-generator/FILES | 6 + README.md | 3 + api/openapi.yaml | 105 +++++++++ docs/AppsApi.md | 84 +++++++ docs/SyncError.md | 33 +++ docs/SyncErrorList.md | 29 +++ opal_security/__init__.py | 2 + opal_security/api/apps_api.py | 298 ++++++++++++++++++++++++ opal_security/models/__init__.py | 2 + opal_security/models/sync_error.py | 108 +++++++++ opal_security/models/sync_error_list.py | 109 +++++++++ test/test_sync_error.py | 58 +++++ test/test_sync_error_list.py | 57 +++++ 13 files changed, 894 insertions(+) create mode 100644 docs/SyncError.md create mode 100644 docs/SyncErrorList.md create mode 100644 opal_security/models/sync_error.py create mode 100644 opal_security/models/sync_error_list.py create mode 100644 test/test_sync_error.py create mode 100644 test/test_sync_error_list.py diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 8b24904..20022a4 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -139,6 +139,8 @@ docs/Session.md docs/SessionsApi.md docs/SessionsList.md docs/SubEvent.md +docs/SyncError.md +docs/SyncErrorList.md docs/Tag.md docs/TagFilter.md docs/TagsApi.md @@ -315,6 +317,8 @@ opal_security/models/risk_sensitivity_enum.py opal_security/models/session.py opal_security/models/sessions_list.py opal_security/models/sub_event.py +opal_security/models/sync_error.py +opal_security/models/sync_error_list.py opal_security/models/tag.py opal_security/models/tag_filter.py opal_security/models/tags_list.py @@ -349,4 +353,6 @@ setup.cfg setup.py test-requirements.txt test/__init__.py +test/test_sync_error.py +test/test_sync_error_list.py tox.ini diff --git a/README.md b/README.md index 4d5d21a..3e8e131 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,7 @@ Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- *AppsApi* | [**get_app**](docs/AppsApi.md#get_app) | **GET** /apps/{app_id} | *AppsApi* | [**get_apps**](docs/AppsApi.md#get_apps) | **GET** /apps | +*AppsApi* | [**get_sync_errors**](docs/AppsApi.md#get_sync_errors) | **GET** /sync_errors | *ConfigurationTemplatesApi* | [**create_configuration_template**](docs/ConfigurationTemplatesApi.md#create_configuration_template) | **POST** /configuration-templates | *ConfigurationTemplatesApi* | [**delete_configuration_template**](docs/ConfigurationTemplatesApi.md#delete_configuration_template) | **DELETE** /configuration-templates/{configuration_template_id} | *ConfigurationTemplatesApi* | [**get_configuration_templates**](docs/ConfigurationTemplatesApi.md#get_configuration_templates) | **GET** /configuration-templates | @@ -361,6 +362,8 @@ Class | Method | HTTP request | Description - [Session](docs/Session.md) - [SessionsList](docs/SessionsList.md) - [SubEvent](docs/SubEvent.md) + - [SyncError](docs/SyncError.md) + - [SyncErrorList](docs/SyncErrorList.md) - [Tag](docs/Tag.md) - [TagFilter](docs/TagFilter.md) - [TagsList](docs/TagsList.md) diff --git a/api/openapi.yaml b/api/openapi.yaml index 1140595..2a1b4fa 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -3017,6 +3017,54 @@ paths: - BearerAuth: [] tags: - uars + /sync_errors: + get: + description: Returns a list of recent sync errors that have occurred since the last successful sync. + operationId: getSyncErrors + parameters: + - description: The ID of the app to list sync errors for. + example: 29827fb8-f2dd-4e80-9576-28e31e9934ac + explode: false + in: query + name: app_id + required: false + schema: + format: uuid + type: string + style: form + - description: The ID of the resource to list sync errors for. + example: 4baf8423-db0a-4037-a4cf-f79c60cb67a5 + explode: false + in: query + name: resource_id + required: false + schema: + format: uuid + type: string + style: form + - description: The ID of the group to list sync errors for. + example: 9546209c-42c2-4801-96d7-9ec42df0f59c + explode: false + in: query + name: group_id + required: false + schema: + format: uuid + type: string + style: form + responses: + "200": + content: + application/json: + schema: + items: + $ref: "#/components/schemas/SyncErrorList" + type: array + description: A list of sync errors. + security: + - BearerAuth: [] + tags: + - apps components: schemas: UARScope: @@ -7658,6 +7706,63 @@ components: - duration_minutes - resources - groups + SyncErrorList: + example: + sync_errors: + - app_id: b5a5ca27-0ea3-4d86-9199-2126d57d1fbd + first_seen: 2022-07-14T06:59:59Z + last_seen: 2022-08-23T04:32:46Z + error_message: Failed to connect to the remote system - insufficient credentials. + - app_id: b5a5ca27-0ea3-4d86-9199-2126d57d1fbd + first_seen: 2023-04-24T06:59:59Z + last_seen: 2024-08-21T04:32:46Z + error_message: Resource not found. + properties: + sync_errors: + items: + $ref: "#/components/schemas/SyncError" + type: array + type: object + required: + - sync_errors + SyncError: + description: |- + # SyncError Object + ### Description + The `SyncError` object is used to represent a sync error. + + ### Usage Example + List from the `GET Sync Errors` endpoint. + example: + app_id: b5a5ca27-0ea3-4d86-9199-2126d57d1fbd + first_seen: 2022-07-14T06:59:59Z + last_seen: 2022-08-23T04:32:46Z + error_message: Failed to connect to the remote system - insufficient credentials. + properties: + first_seen: + description: The time when this error was first seen. + example: 2022-07-14T06:59:59Z + type: string + format: date-time + last_seen: + description: The time when this error was most recently seen. + example: 2022-07-14T06:59:59Z + type: string + format: date-time + error_message: + description: The error message associated with the sync error. + example: Failed to connect to the remote system - insufficient credentials. + type: string + app_id: + description: The ID of the app that the error occured for. + example: b5a5ca27-0ea3-4d86-9199-2126d57d1fbd + format: uuid + type: string + required: + - first_seen + - last_seen + - error_message + type: object securitySchemes: BearerAuth: scheme: bearer diff --git a/docs/AppsApi.md b/docs/AppsApi.md index 544a6bb..41adb4f 100644 --- a/docs/AppsApi.md +++ b/docs/AppsApi.md @@ -6,6 +6,7 @@ Method | HTTP request | Description ------------- | ------------- | ------------- [**get_app**](AppsApi.md#get_app) | **GET** /apps/{app_id} | [**get_apps**](AppsApi.md#get_apps) | **GET** /apps | +[**get_sync_errors**](AppsApi.md#get_sync_errors) | **GET** /sync_errors | # **get_app** @@ -169,3 +170,86 @@ 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) +# **get_sync_errors** +> List[SyncErrorList] get_sync_errors(app_id=app_id, resource_id=resource_id, group_id=group_id) + + + +Returns a list of recent sync errors that have occurred since the last successful sync. + +### Example + +* Bearer Authentication (BearerAuth): + +```python +import opal_security +from opal_security.models.sync_error_list import SyncErrorList +from opal_security.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://api.opal.dev/v1 +# See configuration.py for a list of all supported configuration parameters. +import opal_security as opal + +configuration = opal.Configuration( + host = "https://api.opal.dev/v1" +) + +# 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 Bearer authorization: BearerAuth +configuration = opal.Configuration( + access_token = os.environ["BEARER_TOKEN"] +) + +# Enter a context with an instance of the API client +with opal_security.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = opal_security.AppsApi(api_client) + app_id = '29827fb8-f2dd-4e80-9576-28e31e9934ac' # str | The ID of the app to list sync errors for. (optional) + resource_id = '4baf8423-db0a-4037-a4cf-f79c60cb67a5' # str | The ID of the resource to list sync errors for. (optional) + group_id = '9546209c-42c2-4801-96d7-9ec42df0f59c' # str | The ID of the group to list sync errors for. (optional) + + try: + api_response = api_instance.get_sync_errors(app_id=app_id, resource_id=resource_id, group_id=group_id) + print("The response of AppsApi->get_sync_errors:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling AppsApi->get_sync_errors: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **app_id** | **str**| The ID of the app to list sync errors for. | [optional] + **resource_id** | **str**| The ID of the resource to list sync errors for. | [optional] + **group_id** | **str**| The ID of the group to list sync errors for. | [optional] + +### Return type + +[**List[SyncErrorList]**](SyncErrorList.md) + +### Authorization + +[BearerAuth](../README.md#BearerAuth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | A list of sync errors. | - | + +[[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/SyncError.md b/docs/SyncError.md new file mode 100644 index 0000000..caeb41e --- /dev/null +++ b/docs/SyncError.md @@ -0,0 +1,33 @@ +# SyncError + +# SyncError Object ### Description The `SyncError` object is used to represent a sync error. ### Usage Example List from the `GET Sync Errors` endpoint. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**first_seen** | **datetime** | The time when this error was first seen. | +**last_seen** | **datetime** | The time when this error was most recently seen. | +**error_message** | **str** | The error message associated with the sync error. | +**app_id** | **str** | The ID of the app that the error occured for. | [optional] + +## Example + +```python +from opal_security.models.sync_error import SyncError + +# TODO update the JSON string below +json = "{}" +# create an instance of SyncError from a JSON string +sync_error_instance = SyncError.from_json(json) +# print the JSON string representation of the object +print(SyncError.to_json()) + +# convert the object into a dict +sync_error_dict = sync_error_instance.to_dict() +# create an instance of SyncError from a dict +sync_error_from_dict = SyncError.from_dict(sync_error_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/SyncErrorList.md b/docs/SyncErrorList.md new file mode 100644 index 0000000..c36597e --- /dev/null +++ b/docs/SyncErrorList.md @@ -0,0 +1,29 @@ +# SyncErrorList + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**sync_errors** | [**List[SyncError]**](SyncError.md) | | + +## Example + +```python +from opal_security.models.sync_error_list import SyncErrorList + +# TODO update the JSON string below +json = "{}" +# create an instance of SyncErrorList from a JSON string +sync_error_list_instance = SyncErrorList.from_json(json) +# print the JSON string representation of the object +print(SyncErrorList.to_json()) + +# convert the object into a dict +sync_error_list_dict = sync_error_list_instance.to_dict() +# create an instance of SyncErrorList from a dict +sync_error_list_from_dict = SyncErrorList.from_dict(sync_error_list_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/opal_security/__init__.py b/opal_security/__init__.py index b83051c..86ec533 100644 --- a/opal_security/__init__.py +++ b/opal_security/__init__.py @@ -170,6 +170,8 @@ from opal_security.models.session import Session from opal_security.models.sessions_list import SessionsList from opal_security.models.sub_event import SubEvent +from opal_security.models.sync_error import SyncError +from opal_security.models.sync_error_list import SyncErrorList from opal_security.models.tag import Tag from opal_security.models.tag_filter import TagFilter from opal_security.models.tags_list import TagsList diff --git a/opal_security/api/apps_api.py b/opal_security/api/apps_api.py index 03b3bd2..afdf18e 100644 --- a/opal_security/api/apps_api.py +++ b/opal_security/api/apps_api.py @@ -23,6 +23,7 @@ from opal_security.models.app import App from opal_security.models.app_type_enum import AppTypeEnum from opal_security.models.apps_list import AppsList +from opal_security.models.sync_error_list import SyncErrorList from opal_security.api_client import ApiClient, RequestSerialized from opal_security.api_response import ApiResponse @@ -582,3 +583,300 @@ def _get_apps_serialize( ) + + + @validate_call + def get_sync_errors( + self, + app_id: Annotated[Optional[StrictStr], Field(description="The ID of the app to list sync errors for.")] = None, + resource_id: Annotated[Optional[StrictStr], Field(description="The ID of the resource to list sync errors for.")] = None, + group_id: Annotated[Optional[StrictStr], Field(description="The ID of the group to list sync errors for.")] = 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[SyncErrorList]: + """get_sync_errors + + Returns a list of recent sync errors that have occurred since the last successful sync. + + :param app_id: The ID of the app to list sync errors for. + :type app_id: str + :param resource_id: The ID of the resource to list sync errors for. + :type resource_id: str + :param group_id: The ID of the group to list sync errors for. + :type group_id: str + :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_sync_errors_serialize( + app_id=app_id, + resource_id=resource_id, + group_id=group_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "List[SyncErrorList]", + } + 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_sync_errors_with_http_info( + self, + app_id: Annotated[Optional[StrictStr], Field(description="The ID of the app to list sync errors for.")] = None, + resource_id: Annotated[Optional[StrictStr], Field(description="The ID of the resource to list sync errors for.")] = None, + group_id: Annotated[Optional[StrictStr], Field(description="The ID of the group to list sync errors for.")] = 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[SyncErrorList]]: + """get_sync_errors + + Returns a list of recent sync errors that have occurred since the last successful sync. + + :param app_id: The ID of the app to list sync errors for. + :type app_id: str + :param resource_id: The ID of the resource to list sync errors for. + :type resource_id: str + :param group_id: The ID of the group to list sync errors for. + :type group_id: str + :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_sync_errors_serialize( + app_id=app_id, + resource_id=resource_id, + group_id=group_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "List[SyncErrorList]", + } + 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_sync_errors_without_preload_content( + self, + app_id: Annotated[Optional[StrictStr], Field(description="The ID of the app to list sync errors for.")] = None, + resource_id: Annotated[Optional[StrictStr], Field(description="The ID of the resource to list sync errors for.")] = None, + group_id: Annotated[Optional[StrictStr], Field(description="The ID of the group to list sync errors for.")] = 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: + """get_sync_errors + + Returns a list of recent sync errors that have occurred since the last successful sync. + + :param app_id: The ID of the app to list sync errors for. + :type app_id: str + :param resource_id: The ID of the resource to list sync errors for. + :type resource_id: str + :param group_id: The ID of the group to list sync errors for. + :type group_id: str + :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_sync_errors_serialize( + app_id=app_id, + resource_id=resource_id, + group_id=group_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "List[SyncErrorList]", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _get_sync_errors_serialize( + self, + app_id, + resource_id, + group_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, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if app_id is not None: + + _query_params.append(('app_id', app_id)) + + if resource_id is not None: + + _query_params.append(('resource_id', resource_id)) + + if group_id is not None: + + _query_params.append(('group_id', group_id)) + + # 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] = [ + 'BearerAuth' + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/sync_errors', + 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/opal_security/models/__init__.py b/opal_security/models/__init__.py index 5462a4e..86e8eae 100644 --- a/opal_security/models/__init__.py +++ b/opal_security/models/__init__.py @@ -138,6 +138,8 @@ from opal_security.models.session import Session from opal_security.models.sessions_list import SessionsList from opal_security.models.sub_event import SubEvent +from opal_security.models.sync_error import SyncError +from opal_security.models.sync_error_list import SyncErrorList from opal_security.models.tag import Tag from opal_security.models.tag_filter import TagFilter from opal_security.models.tags_list import TagsList diff --git a/opal_security/models/sync_error.py b/opal_security/models/sync_error.py new file mode 100644 index 0000000..030fe05 --- /dev/null +++ b/opal_security/models/sync_error.py @@ -0,0 +1,108 @@ +# coding: utf-8 + +""" + Opal API + + The Opal API is a RESTful API that allows you to interact with the Opal Security platform programmatically. + + The version of the OpenAPI document: 1.0 + Contact: hello@opal.dev + 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, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class SyncError(BaseModel): + """ + # SyncError Object ### Description The `SyncError` object is used to represent a sync error. ### Usage Example List from the `GET Sync Errors` endpoint. + """ # noqa: E501 + first_seen: datetime = Field(description="The time when this error was first seen.") + last_seen: datetime = Field(description="The time when this error was most recently seen.") + error_message: StrictStr = Field(description="The error message associated with the sync error.") + app_id: Optional[StrictStr] = Field(default=None, description="The ID of the app that the error occured for.") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["first_seen", "last_seen", "error_message", "app_id"] + + 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 SyncError 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 + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of SyncError from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "first_seen": obj.get("first_seen"), + "last_seen": obj.get("last_seen"), + "error_message": obj.get("error_message"), + "app_id": obj.get("app_id") + }) + # 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/opal_security/models/sync_error_list.py b/opal_security/models/sync_error_list.py new file mode 100644 index 0000000..488d2ae --- /dev/null +++ b/opal_security/models/sync_error_list.py @@ -0,0 +1,109 @@ +# coding: utf-8 + +""" + Opal API + + The Opal API is a RESTful API that allows you to interact with the Opal Security platform programmatically. + + The version of the OpenAPI document: 1.0 + Contact: hello@opal.dev + 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 +from typing import Any, ClassVar, Dict, List +from opal_security.models.sync_error import SyncError +from typing import Optional, Set +from typing_extensions import Self + +class SyncErrorList(BaseModel): + """ + SyncErrorList + """ # noqa: E501 + sync_errors: List[SyncError] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["sync_errors"] + + 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 SyncErrorList 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 sync_errors (list) + _items = [] + if self.sync_errors: + for _item_sync_errors in self.sync_errors: + if _item_sync_errors: + _items.append(_item_sync_errors.to_dict()) + _dict['sync_errors'] = _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 + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of SyncErrorList from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "sync_errors": [SyncError.from_dict(_item) for _item in obj["sync_errors"]] if obj.get("sync_errors") 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 + + diff --git a/test/test_sync_error.py b/test/test_sync_error.py new file mode 100644 index 0000000..5bf7eb0 --- /dev/null +++ b/test/test_sync_error.py @@ -0,0 +1,58 @@ +# coding: utf-8 + +""" + Opal API + + The Opal API is a RESTful API that allows you to interact with the Opal Security platform programmatically. + + The version of the OpenAPI document: 1.0 + Contact: hello@opal.dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from opal_security.models.sync_error import SyncError + +class TestSyncError(unittest.TestCase): + """SyncError unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> SyncError: + """Test SyncError + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `SyncError` + """ + model = SyncError() + if include_optional: + return SyncError( + first_seen = '2022-07-14T06:59:59Z', + last_seen = '2022-07-14T06:59:59Z', + error_message = 'Failed to connect to the remote system - insufficient credentials.', + app_id = 'b5a5ca27-0ea3-4d86-9199-2126d57d1fbd' + ) + else: + return SyncError( + first_seen = '2022-07-14T06:59:59Z', + last_seen = '2022-07-14T06:59:59Z', + error_message = 'Failed to connect to the remote system - insufficient credentials.', + ) + """ + + def testSyncError(self): + """Test SyncError""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/test/test_sync_error_list.py b/test/test_sync_error_list.py new file mode 100644 index 0000000..b4d7780 --- /dev/null +++ b/test/test_sync_error_list.py @@ -0,0 +1,57 @@ +# coding: utf-8 + +""" + Opal API + + The Opal API is a RESTful API that allows you to interact with the Opal Security platform programmatically. + + The version of the OpenAPI document: 1.0 + Contact: hello@opal.dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from opal_security.models.sync_error_list import SyncErrorList + +class TestSyncErrorList(unittest.TestCase): + """SyncErrorList unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> SyncErrorList: + """Test SyncErrorList + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `SyncErrorList` + """ + model = SyncErrorList() + if include_optional: + return SyncErrorList( + sync_errors = [ + {app_id=b5a5ca27-0ea3-4d86-9199-2126d57d1fbd, first_seen=2022-07-14T06:59:59Z, last_seen=2022-08-23T04:32:46Z, error_message=Failed to connect to the remote system - insufficient credentials.} + ] + ) + else: + return SyncErrorList( + sync_errors = [ + {app_id=b5a5ca27-0ea3-4d86-9199-2126d57d1fbd, first_seen=2022-07-14T06:59:59Z, last_seen=2022-08-23T04:32:46Z, error_message=Failed to connect to the remote system - insufficient credentials.} + ], + ) + """ + + def testSyncErrorList(self): + """Test SyncErrorList""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main()