From ee5bc4f85a0fe5a9922d68a0a53b88f12173acf3 Mon Sep 17 00:00:00 2001 From: SDK Generator Bot Date: Fri, 13 Mar 2026 12:27:33 +0000 Subject: [PATCH] Generate auditlog --- services/auditlog/oas_commit | 1 + .../src/stackit/auditlog/api/default_api.py | 37 ++++++++++--------- .../src/stackit/auditlog/api_client.py | 31 +++++++++++----- .../src/stackit/auditlog/exceptions.py | 2 +- .../src/stackit/auditlog/models/__init__.py | 1 - ...ervice_account_delegation_info_response.py | 6 +-- .../models/list_audit_log_entries_response.py | 6 +-- .../auditlog/src/stackit/auditlog/rest.py | 22 +++++++++-- 8 files changed, 68 insertions(+), 38 deletions(-) create mode 100644 services/auditlog/oas_commit diff --git a/services/auditlog/oas_commit b/services/auditlog/oas_commit new file mode 100644 index 000000000..e3713dde3 --- /dev/null +++ b/services/auditlog/oas_commit @@ -0,0 +1 @@ +0e64886dd0847341800d7191ed193b75413be998 diff --git a/services/auditlog/src/stackit/auditlog/api/default_api.py b/services/auditlog/src/stackit/auditlog/api/default_api.py index 1c3f47e3a..03c43abdf 100644 --- a/services/auditlog/src/stackit/auditlog/api/default_api.py +++ b/services/auditlog/src/stackit/auditlog/api/default_api.py @@ -13,6 +13,7 @@ from datetime import datetime from typing import Any, Dict, List, Optional, Tuple, Union +from uuid import UUID from pydantic import Field, StrictFloat, StrictInt, StrictStr, validate_call from stackit.core.configuration import Configuration @@ -42,7 +43,7 @@ def __init__(self, configuration: Configuration = None) -> None: @validate_call def list_folder_audit_log_entries( self, - folder_id: Annotated[StrictStr, Field(description="ID of the folder for which entries should be returned.")], + folder_id: Annotated[UUID, Field(description="ID of the folder for which entries should be returned.")], start_time_range: Annotated[ datetime, Field( @@ -86,7 +87,7 @@ def list_folder_audit_log_entries( Returns all audit log entries of the folder for the specified period. \\ Period must not be longer than 24 hours within the last 90 days. :param folder_id: ID of the folder for which entries should be returned. (required) - :type folder_id: str + :type folder_id: UUID :param start_time_range: An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time. (required) :type start_time_range: datetime :param end_time_range: An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received. (required) @@ -146,7 +147,7 @@ def list_folder_audit_log_entries( @validate_call def list_folder_audit_log_entries_with_http_info( self, - folder_id: Annotated[StrictStr, Field(description="ID of the folder for which entries should be returned.")], + folder_id: Annotated[UUID, Field(description="ID of the folder for which entries should be returned.")], start_time_range: Annotated[ datetime, Field( @@ -190,7 +191,7 @@ def list_folder_audit_log_entries_with_http_info( Returns all audit log entries of the folder for the specified period. \\ Period must not be longer than 24 hours within the last 90 days. :param folder_id: ID of the folder for which entries should be returned. (required) - :type folder_id: str + :type folder_id: UUID :param start_time_range: An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time. (required) :type start_time_range: datetime :param end_time_range: An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received. (required) @@ -250,7 +251,7 @@ def list_folder_audit_log_entries_with_http_info( @validate_call def list_folder_audit_log_entries_without_preload_content( self, - folder_id: Annotated[StrictStr, Field(description="ID of the folder for which entries should be returned.")], + folder_id: Annotated[UUID, Field(description="ID of the folder for which entries should be returned.")], start_time_range: Annotated[ datetime, Field( @@ -294,7 +295,7 @@ def list_folder_audit_log_entries_without_preload_content( Returns all audit log entries of the folder for the specified period. \\ Period must not be longer than 24 hours within the last 90 days. :param folder_id: ID of the folder for which entries should be returned. (required) - :type folder_id: str + :type folder_id: UUID :param start_time_range: An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time. (required) :type start_time_range: datetime :param end_time_range: An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received. (required) @@ -429,7 +430,7 @@ def _list_folder_audit_log_entries_serialize( def list_organization_audit_log_entries( self, organization_id: Annotated[ - StrictStr, Field(description="ID of the organization for which entries should be returned.") + UUID, Field(description="ID of the organization for which entries should be returned.") ], start_time_range: Annotated[ datetime, @@ -474,7 +475,7 @@ def list_organization_audit_log_entries( Returns all audit log entries of the organization for the specified period. \\ Period must not be longer than 24 hours within the last 90 days. :param organization_id: ID of the organization for which entries should be returned. (required) - :type organization_id: str + :type organization_id: UUID :param start_time_range: An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time. (required) :type start_time_range: datetime :param end_time_range: An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received. (required) @@ -535,7 +536,7 @@ def list_organization_audit_log_entries( def list_organization_audit_log_entries_with_http_info( self, organization_id: Annotated[ - StrictStr, Field(description="ID of the organization for which entries should be returned.") + UUID, Field(description="ID of the organization for which entries should be returned.") ], start_time_range: Annotated[ datetime, @@ -580,7 +581,7 @@ def list_organization_audit_log_entries_with_http_info( Returns all audit log entries of the organization for the specified period. \\ Period must not be longer than 24 hours within the last 90 days. :param organization_id: ID of the organization for which entries should be returned. (required) - :type organization_id: str + :type organization_id: UUID :param start_time_range: An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time. (required) :type start_time_range: datetime :param end_time_range: An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received. (required) @@ -641,7 +642,7 @@ def list_organization_audit_log_entries_with_http_info( def list_organization_audit_log_entries_without_preload_content( self, organization_id: Annotated[ - StrictStr, Field(description="ID of the organization for which entries should be returned.") + UUID, Field(description="ID of the organization for which entries should be returned.") ], start_time_range: Annotated[ datetime, @@ -686,7 +687,7 @@ def list_organization_audit_log_entries_without_preload_content( Returns all audit log entries of the organization for the specified period. \\ Period must not be longer than 24 hours within the last 90 days. :param organization_id: ID of the organization for which entries should be returned. (required) - :type organization_id: str + :type organization_id: UUID :param start_time_range: An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time. (required) :type start_time_range: datetime :param end_time_range: An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received. (required) @@ -820,7 +821,7 @@ def _list_organization_audit_log_entries_serialize( @validate_call def list_project_audit_log_entries( self, - project_id: Annotated[StrictStr, Field(description="ID of the project for which entries should be returned.")], + project_id: Annotated[UUID, Field(description="ID of the project for which entries should be returned.")], start_time_range: Annotated[ datetime, Field( @@ -864,7 +865,7 @@ def list_project_audit_log_entries( Returns all audit log entries of the project for the specified period. \\ Period must not be longer than 24 hours within the last 90 days. :param project_id: ID of the project for which entries should be returned. (required) - :type project_id: str + :type project_id: UUID :param start_time_range: An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time. (required) :type start_time_range: datetime :param end_time_range: An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received. (required) @@ -924,7 +925,7 @@ def list_project_audit_log_entries( @validate_call def list_project_audit_log_entries_with_http_info( self, - project_id: Annotated[StrictStr, Field(description="ID of the project for which entries should be returned.")], + project_id: Annotated[UUID, Field(description="ID of the project for which entries should be returned.")], start_time_range: Annotated[ datetime, Field( @@ -968,7 +969,7 @@ def list_project_audit_log_entries_with_http_info( Returns all audit log entries of the project for the specified period. \\ Period must not be longer than 24 hours within the last 90 days. :param project_id: ID of the project for which entries should be returned. (required) - :type project_id: str + :type project_id: UUID :param start_time_range: An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time. (required) :type start_time_range: datetime :param end_time_range: An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received. (required) @@ -1028,7 +1029,7 @@ def list_project_audit_log_entries_with_http_info( @validate_call def list_project_audit_log_entries_without_preload_content( self, - project_id: Annotated[StrictStr, Field(description="ID of the project for which entries should be returned.")], + project_id: Annotated[UUID, Field(description="ID of the project for which entries should be returned.")], start_time_range: Annotated[ datetime, Field( @@ -1072,7 +1073,7 @@ def list_project_audit_log_entries_without_preload_content( Returns all audit log entries of the project for the specified period. \\ Period must not be longer than 24 hours within the last 90 days. :param project_id: ID of the project for which entries should be returned. (required) - :type project_id: str + :type project_id: UUID :param start_time_range: An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time. (required) :type start_time_range: datetime :param end_time_range: An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received. (required) diff --git a/services/auditlog/src/stackit/auditlog/api_client.py b/services/auditlog/src/stackit/auditlog/api_client.py index d0308cb0c..250b7f3f1 100644 --- a/services/auditlog/src/stackit/auditlog/api_client.py +++ b/services/auditlog/src/stackit/auditlog/api_client.py @@ -12,11 +12,13 @@ """ # noqa: E501 import datetime +import decimal import json import mimetypes import os import re import tempfile +import uuid from enum import Enum from typing import Dict, List, Optional, Tuple, Union from urllib.parse import quote @@ -63,8 +65,10 @@ class ApiClient: "bool": bool, "date": datetime.date, "datetime": datetime.datetime, + "decimal": decimal.Decimal, "object": object, } + _pool = None def __init__(self, configuration, header_name=None, header_value=None, cookie=None) -> None: self.config: Configuration = configuration @@ -267,7 +271,7 @@ def response_deserialize( return_data = self.__deserialize_file(response_data) elif response_type is not None: match = None - content_type = response_data.getheader("content-type") + content_type = response_data.headers.get("content-type") if content_type is not None: match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type) encoding = match.group(1) if match else "utf-8" @@ -284,7 +288,7 @@ def response_deserialize( return ApiResponse( status_code=response_data.status, data=return_data, - headers=response_data.getheaders(), + headers=response_data.headers, raw_data=response_data.data, ) @@ -296,6 +300,7 @@ def sanitize_for_serialization(self, obj): If obj is str, int, long, float, bool, return directly. If obj is datetime.datetime, datetime.date convert to string in iso8601 format. + If obj is decimal.Decimal return string representation. If obj is list, sanitize each element in the list. If obj is dict, return the dict. If obj is OpenAPI model, return the properties dict. @@ -311,12 +316,16 @@ def sanitize_for_serialization(self, obj): return obj.get_secret_value() elif isinstance(obj, self.PRIMITIVE_TYPES): return obj + elif isinstance(obj, uuid.UUID): + return str(obj) elif isinstance(obj, list): return [self.sanitize_for_serialization(sub_obj) for sub_obj in obj] elif isinstance(obj, tuple): return tuple(self.sanitize_for_serialization(sub_obj) for sub_obj in obj) elif isinstance(obj, (datetime.datetime, datetime.date)): return obj.isoformat() + elif isinstance(obj, decimal.Decimal): + return str(obj) elif isinstance(obj, dict): obj_dict = obj @@ -326,7 +335,7 @@ def sanitize_for_serialization(self, obj): # and attributes which value is not None. # Convert attribute name to json key in # model definition for request. - if hasattr(obj, "to_dict") and callable(obj.to_dict): + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): obj_dict = obj.to_dict() else: obj_dict = obj.__dict__ @@ -354,7 +363,7 @@ def deserialize(self, response_text: str, response_type: str, content_type: Opti data = json.loads(response_text) except ValueError: data = response_text - elif re.match(r"^application/(json|[\w!#$&.+-^_]+\+json)\s*(;|$)", content_type, re.IGNORECASE): + elif re.match(r"^application/(json|[\w!#$&.+\-^_]+\+json)\s*(;|$)", content_type, re.IGNORECASE): if response_text == "": data = "" else: @@ -400,12 +409,14 @@ def __deserialize(self, data, klass): if klass in self.PRIMITIVE_TYPES: return self.__deserialize_primitive(data, klass) - elif klass == object: + elif klass is object: return self.__deserialize_object(data) - elif klass == datetime.date: + elif klass is datetime.date: return self.__deserialize_date(data) - elif klass == datetime.datetime: + elif klass is datetime.datetime: return self.__deserialize_datetime(data) + elif klass is decimal.Decimal: + return decimal.Decimal(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) else: @@ -553,12 +564,14 @@ def __deserialize_file(self, response): os.close(fd) os.remove(path) - content_disposition = response.getheader("Content-Disposition") + content_disposition = response.headers.get("Content-Disposition") if content_disposition: m = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', content_disposition) if m is None: raise ValueError("Unexpected 'content-disposition' header value") - filename = m.group(1) + filename = os.path.basename(m.group(1)) # Strip any directory traversal + if filename in ("", ".", ".."): # fall back to tmp filename + filename = os.path.basename(path) path = os.path.join(os.path.dirname(path), filename) with open(path, "wb") as f: diff --git a/services/auditlog/src/stackit/auditlog/exceptions.py b/services/auditlog/src/stackit/auditlog/exceptions.py index 442e08ff6..00c6ebc4a 100644 --- a/services/auditlog/src/stackit/auditlog/exceptions.py +++ b/services/auditlog/src/stackit/auditlog/exceptions.py @@ -129,7 +129,7 @@ def __init__( self.body = http_resp.data.decode("utf-8") except Exception: # noqa: S110 pass - self.headers = http_resp.getheaders() + self.headers = http_resp.headers @classmethod def from_response( diff --git a/services/auditlog/src/stackit/auditlog/models/__init__.py b/services/auditlog/src/stackit/auditlog/models/__init__.py index 94a6a3761..8171a2611 100644 --- a/services/auditlog/src/stackit/auditlog/models/__init__.py +++ b/services/auditlog/src/stackit/auditlog/models/__init__.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ # noqa: E501 - # import models into model package from stackit.auditlog.models.audit_log_entry_context_response import ( AuditLogEntryContextResponse, diff --git a/services/auditlog/src/stackit/auditlog/models/audit_log_entry_service_account_delegation_info_response.py b/services/auditlog/src/stackit/auditlog/models/audit_log_entry_service_account_delegation_info_response.py index e490f43e8..b4e12323d 100644 --- a/services/auditlog/src/stackit/auditlog/models/audit_log_entry_service_account_delegation_info_response.py +++ b/services/auditlog/src/stackit/auditlog/models/audit_log_entry_service_account_delegation_info_response.py @@ -75,9 +75,9 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of each item in principals (list) _items = [] if self.principals: - for _item in self.principals: - if _item: - _items.append(_item.to_dict()) + for _item_principals in self.principals: + if _item_principals: + _items.append(_item_principals.to_dict()) _dict["principals"] = _items return _dict diff --git a/services/auditlog/src/stackit/auditlog/models/list_audit_log_entries_response.py b/services/auditlog/src/stackit/auditlog/models/list_audit_log_entries_response.py index 848e30d45..02cc150d4 100644 --- a/services/auditlog/src/stackit/auditlog/models/list_audit_log_entries_response.py +++ b/services/auditlog/src/stackit/auditlog/models/list_audit_log_entries_response.py @@ -82,9 +82,9 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of each item in items (list) _items = [] if self.items: - for _item in self.items: - if _item: - _items.append(_item.to_dict()) + for _item_items in self.items: + if _item_items: + _items.append(_item_items.to_dict()) _dict["items"] = _items return _dict diff --git a/services/auditlog/src/stackit/auditlog/rest.py b/services/auditlog/src/stackit/auditlog/rest.py index de7a2a44d..cb943d1ff 100644 --- a/services/auditlog/src/stackit/auditlog/rest.py +++ b/services/auditlog/src/stackit/auditlog/rest.py @@ -38,12 +38,17 @@ def read(self): self.data = self.response.content return self.data + @property + def headers(self): + """Returns a dictionary of response headers.""" + return self.response.headers + def getheaders(self): - """Returns a dictionary of the response headers.""" + """Returns a dictionary of the response headers; use ``headers`` instead.""" return self.response.headers def getheader(self, name, default=None): - """Returns a given response header.""" + """Returns a given response header; use ``headers.get()`` instead.""" return self.response.headers.get(name, default) @@ -93,6 +98,7 @@ def request(self, method, url, headers=None, body=None, post_params=None, _reque url, data=request_body, headers=headers, + timeout=_request_timeout, ) elif content_type == "application/x-www-form-urlencoded": r = self.session.request( @@ -100,6 +106,7 @@ def request(self, method, url, headers=None, body=None, post_params=None, _reque url, params=post_params, headers=headers, + timeout=_request_timeout, ) elif content_type == "multipart/form-data": # must del headers['Content-Type'], or the correct @@ -113,6 +120,7 @@ def request(self, method, url, headers=None, body=None, post_params=None, _reque url, files=post_params, headers=headers, + timeout=_request_timeout, ) # Pass a `string` parameter directly in the body to support # other content types than JSON when `body` argument is @@ -123,10 +131,17 @@ def request(self, method, url, headers=None, body=None, post_params=None, _reque url, data=body, headers=headers, + timeout=_request_timeout, ) elif headers["Content-Type"].startswith("text/") and isinstance(body, bool): request_body = "true" if body else "false" - r = self.session.request(method, url, data=request_body, headers=headers) + r = self.session.request( + method, + url, + data=request_body, + headers=headers, + timeout=_request_timeout, + ) else: # Cannot generate the request from given parameters msg = """Cannot prepare a request message for provided @@ -140,6 +155,7 @@ def request(self, method, url, headers=None, body=None, post_params=None, _reque url, params={}, headers=headers, + timeout=_request_timeout, ) except requests.exceptions.SSLError as e: msg = "\n".join([type(e).__name__, str(e)])