diff --git a/services/serviceaccount/oas_commit b/services/serviceaccount/oas_commit index f137f4d6..e3713dde 100644 --- a/services/serviceaccount/oas_commit +++ b/services/serviceaccount/oas_commit @@ -1 +1 @@ -cb550f3c2129447568c2855337b1874968e033bb +0e64886dd0847341800d7191ed193b75413be998 diff --git a/services/serviceaccount/src/stackit/serviceaccount/api/default_api.py b/services/serviceaccount/src/stackit/serviceaccount/api/default_api.py index 0d7918e1..5170e4db 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/api/default_api.py +++ b/services/serviceaccount/src/stackit/serviceaccount/api/default_api.py @@ -12,6 +12,7 @@ """ # noqa: E501 from typing import Any, Dict, List, Optional, Tuple, Union +from uuid import UUID from pydantic import ( Field, @@ -1528,7 +1529,7 @@ def delete_access_token( self, project_id: Annotated[StrictStr, Field(description="The ID of the project.")], service_account_email: Annotated[StrictStr, Field(description="The ID of the Service Account.")], - access_token_id: Annotated[StrictStr, Field(description="The ID of the Access Token.")], + access_token_id: Annotated[UUID, Field(description="The ID of the Access Token.")], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -1548,7 +1549,7 @@ def delete_access_token( :param service_account_email: The ID of the Service Account. (required) :type service_account_email: str :param access_token_id: The ID of the Access Token. (required) - :type access_token_id: str + :type access_token_id: UUID :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 @@ -1601,7 +1602,7 @@ def delete_access_token_with_http_info( self, project_id: Annotated[StrictStr, Field(description="The ID of the project.")], service_account_email: Annotated[StrictStr, Field(description="The ID of the Service Account.")], - access_token_id: Annotated[StrictStr, Field(description="The ID of the Access Token.")], + access_token_id: Annotated[UUID, Field(description="The ID of the Access Token.")], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -1621,7 +1622,7 @@ def delete_access_token_with_http_info( :param service_account_email: The ID of the Service Account. (required) :type service_account_email: str :param access_token_id: The ID of the Access Token. (required) - :type access_token_id: str + :type access_token_id: UUID :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 @@ -1674,7 +1675,7 @@ def delete_access_token_without_preload_content( self, project_id: Annotated[StrictStr, Field(description="The ID of the project.")], service_account_email: Annotated[StrictStr, Field(description="The ID of the Service Account.")], - access_token_id: Annotated[StrictStr, Field(description="The ID of the Access Token.")], + access_token_id: Annotated[UUID, Field(description="The ID of the Access Token.")], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -1694,7 +1695,7 @@ def delete_access_token_without_preload_content( :param service_account_email: The ID of the Service Account. (required) :type service_account_email: str :param access_token_id: The ID of the Access Token. (required) - :type access_token_id: str + :type access_token_id: UUID :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 @@ -2052,7 +2053,7 @@ def delete_service_account_key( self, project_id: Annotated[StrictStr, Field(description="The ID of the project.")], service_account_email: Annotated[StrictStr, Field(description="The email of the service account.")], - key_id: Annotated[StrictStr, Field(description="ID of the key.")], + key_id: Annotated[UUID, Field(description="ID of the key.")], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -2072,7 +2073,7 @@ def delete_service_account_key( :param service_account_email: The email of the service account. (required) :type service_account_email: str :param key_id: ID of the key. (required) - :type key_id: str + :type key_id: UUID :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 @@ -2123,7 +2124,7 @@ def delete_service_account_key_with_http_info( self, project_id: Annotated[StrictStr, Field(description="The ID of the project.")], service_account_email: Annotated[StrictStr, Field(description="The email of the service account.")], - key_id: Annotated[StrictStr, Field(description="ID of the key.")], + key_id: Annotated[UUID, Field(description="ID of the key.")], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -2143,7 +2144,7 @@ def delete_service_account_key_with_http_info( :param service_account_email: The email of the service account. (required) :type service_account_email: str :param key_id: ID of the key. (required) - :type key_id: str + :type key_id: UUID :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 @@ -2194,7 +2195,7 @@ def delete_service_account_key_without_preload_content( self, project_id: Annotated[StrictStr, Field(description="The ID of the project.")], service_account_email: Annotated[StrictStr, Field(description="The email of the service account.")], - key_id: Annotated[StrictStr, Field(description="ID of the key.")], + key_id: Annotated[UUID, Field(description="ID of the key.")], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -2214,7 +2215,7 @@ def delete_service_account_key_without_preload_content( :param service_account_email: The email of the service account. (required) :type service_account_email: str :param key_id: ID of the key. (required) - :type key_id: str + :type key_id: UUID :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 @@ -2317,7 +2318,7 @@ def delete_service_federated_identity_provider( self, project_id: Annotated[StrictStr, Field(description="The ID of the project.")], service_account_email: Annotated[StrictStr, Field(description="The email of the service account.")], - federation_id: Annotated[StrictStr, Field(description="ID of the Federated Identity Provider.")], + federation_id: Annotated[UUID, Field(description="ID of the Federated Identity Provider.")], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -2337,7 +2338,7 @@ def delete_service_federated_identity_provider( :param service_account_email: The email of the service account. (required) :type service_account_email: str :param federation_id: ID of the Federated Identity Provider. (required) - :type federation_id: str + :type federation_id: UUID :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 @@ -2389,7 +2390,7 @@ def delete_service_federated_identity_provider_with_http_info( self, project_id: Annotated[StrictStr, Field(description="The ID of the project.")], service_account_email: Annotated[StrictStr, Field(description="The email of the service account.")], - federation_id: Annotated[StrictStr, Field(description="ID of the Federated Identity Provider.")], + federation_id: Annotated[UUID, Field(description="ID of the Federated Identity Provider.")], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -2409,7 +2410,7 @@ def delete_service_federated_identity_provider_with_http_info( :param service_account_email: The email of the service account. (required) :type service_account_email: str :param federation_id: ID of the Federated Identity Provider. (required) - :type federation_id: str + :type federation_id: UUID :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 @@ -2461,7 +2462,7 @@ def delete_service_federated_identity_provider_without_preload_content( self, project_id: Annotated[StrictStr, Field(description="The ID of the project.")], service_account_email: Annotated[StrictStr, Field(description="The email of the service account.")], - federation_id: Annotated[StrictStr, Field(description="ID of the Federated Identity Provider.")], + federation_id: Annotated[UUID, Field(description="ID of the Federated Identity Provider.")], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -2481,7 +2482,7 @@ def delete_service_federated_identity_provider_without_preload_content( :param service_account_email: The email of the service account. (required) :type service_account_email: str :param federation_id: ID of the Federated Identity Provider. (required) - :type federation_id: str + :type federation_id: UUID :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 @@ -2811,7 +2812,7 @@ def get_service_account_key( self, project_id: Annotated[StrictStr, Field(description="The ID of the project.")], service_account_email: Annotated[StrictStr, Field(description="The email of the service account.")], - key_id: Annotated[StrictStr, Field(description="ID of the key.")], + key_id: Annotated[UUID, Field(description="ID of the key.")], format: Annotated[Optional[StrictStr], Field(description="Requested format for the public key")] = None, _request_timeout: Union[ None, @@ -2832,7 +2833,7 @@ def get_service_account_key( :param service_account_email: The email of the service account. (required) :type service_account_email: str :param key_id: ID of the key. (required) - :type key_id: str + :type key_id: UUID :param format: Requested format for the public key :type format: str :param _request_timeout: timeout setting for this request. If one @@ -2886,7 +2887,7 @@ def get_service_account_key_with_http_info( self, project_id: Annotated[StrictStr, Field(description="The ID of the project.")], service_account_email: Annotated[StrictStr, Field(description="The email of the service account.")], - key_id: Annotated[StrictStr, Field(description="ID of the key.")], + key_id: Annotated[UUID, Field(description="ID of the key.")], format: Annotated[Optional[StrictStr], Field(description="Requested format for the public key")] = None, _request_timeout: Union[ None, @@ -2907,7 +2908,7 @@ def get_service_account_key_with_http_info( :param service_account_email: The email of the service account. (required) :type service_account_email: str :param key_id: ID of the key. (required) - :type key_id: str + :type key_id: UUID :param format: Requested format for the public key :type format: str :param _request_timeout: timeout setting for this request. If one @@ -2961,7 +2962,7 @@ def get_service_account_key_without_preload_content( self, project_id: Annotated[StrictStr, Field(description="The ID of the project.")], service_account_email: Annotated[StrictStr, Field(description="The email of the service account.")], - key_id: Annotated[StrictStr, Field(description="ID of the key.")], + key_id: Annotated[UUID, Field(description="ID of the key.")], format: Annotated[Optional[StrictStr], Field(description="Requested format for the public key")] = None, _request_timeout: Union[ None, @@ -2982,7 +2983,7 @@ def get_service_account_key_without_preload_content( :param service_account_email: The email of the service account. (required) :type service_account_email: str :param key_id: ID of the key. (required) - :type key_id: str + :type key_id: UUID :param format: Requested format for the public key :type format: str :param _request_timeout: timeout setting for this request. If one @@ -4084,7 +4085,7 @@ def partial_update_service_account_federated_identity_provider( self, project_id: Annotated[StrictStr, Field(description="The ID of the project.")], service_account_email: Annotated[StrictStr, Field(description="The email of the service account.")], - federation_id: Annotated[StrictStr, Field(description="ID of the Federated Identity Provider.")], + federation_id: Annotated[UUID, Field(description="ID of the Federated Identity Provider.")], partial_update_service_account_federated_identity_provider_payload: Annotated[ Optional[PartialUpdateServiceAccountFederatedIdentityProviderPayload], Field(description="Delete a Federated Identity Provider"), @@ -4108,7 +4109,7 @@ def partial_update_service_account_federated_identity_provider( :param service_account_email: The email of the service account. (required) :type service_account_email: str :param federation_id: ID of the Federated Identity Provider. (required) - :type federation_id: str + :type federation_id: UUID :param partial_update_service_account_federated_identity_provider_payload: Delete a Federated Identity Provider :type partial_update_service_account_federated_identity_provider_payload: PartialUpdateServiceAccountFederatedIdentityProviderPayload :param _request_timeout: timeout setting for this request. If one @@ -4164,7 +4165,7 @@ def partial_update_service_account_federated_identity_provider_with_http_info( self, project_id: Annotated[StrictStr, Field(description="The ID of the project.")], service_account_email: Annotated[StrictStr, Field(description="The email of the service account.")], - federation_id: Annotated[StrictStr, Field(description="ID of the Federated Identity Provider.")], + federation_id: Annotated[UUID, Field(description="ID of the Federated Identity Provider.")], partial_update_service_account_federated_identity_provider_payload: Annotated[ Optional[PartialUpdateServiceAccountFederatedIdentityProviderPayload], Field(description="Delete a Federated Identity Provider"), @@ -4188,7 +4189,7 @@ def partial_update_service_account_federated_identity_provider_with_http_info( :param service_account_email: The email of the service account. (required) :type service_account_email: str :param federation_id: ID of the Federated Identity Provider. (required) - :type federation_id: str + :type federation_id: UUID :param partial_update_service_account_federated_identity_provider_payload: Delete a Federated Identity Provider :type partial_update_service_account_federated_identity_provider_payload: PartialUpdateServiceAccountFederatedIdentityProviderPayload :param _request_timeout: timeout setting for this request. If one @@ -4244,7 +4245,7 @@ def partial_update_service_account_federated_identity_provider_without_preload_c self, project_id: Annotated[StrictStr, Field(description="The ID of the project.")], service_account_email: Annotated[StrictStr, Field(description="The email of the service account.")], - federation_id: Annotated[StrictStr, Field(description="ID of the Federated Identity Provider.")], + federation_id: Annotated[UUID, Field(description="ID of the Federated Identity Provider.")], partial_update_service_account_federated_identity_provider_payload: Annotated[ Optional[PartialUpdateServiceAccountFederatedIdentityProviderPayload], Field(description="Delete a Federated Identity Provider"), @@ -4268,7 +4269,7 @@ def partial_update_service_account_federated_identity_provider_without_preload_c :param service_account_email: The email of the service account. (required) :type service_account_email: str :param federation_id: ID of the Federated Identity Provider. (required) - :type federation_id: str + :type federation_id: UUID :param partial_update_service_account_federated_identity_provider_payload: Delete a Federated Identity Provider :type partial_update_service_account_federated_identity_provider_payload: PartialUpdateServiceAccountFederatedIdentityProviderPayload :param _request_timeout: timeout setting for this request. If one @@ -4387,7 +4388,7 @@ def partial_update_service_account_key( self, project_id: Annotated[StrictStr, Field(description="The ID of the project.")], service_account_email: Annotated[StrictStr, Field(description="The email of the service account.")], - key_id: Annotated[StrictStr, Field(description="ID of the key.")], + key_id: Annotated[UUID, Field(description="ID of the key.")], partial_update_service_account_key_payload: Annotated[ Optional[PartialUpdateServiceAccountKeyPayload], Field(description="Service account request") ] = None, @@ -4410,7 +4411,7 @@ def partial_update_service_account_key( :param service_account_email: The email of the service account. (required) :type service_account_email: str :param key_id: ID of the key. (required) - :type key_id: str + :type key_id: UUID :param partial_update_service_account_key_payload: Service account request :type partial_update_service_account_key_payload: PartialUpdateServiceAccountKeyPayload :param _request_timeout: timeout setting for this request. If one @@ -4465,7 +4466,7 @@ def partial_update_service_account_key_with_http_info( self, project_id: Annotated[StrictStr, Field(description="The ID of the project.")], service_account_email: Annotated[StrictStr, Field(description="The email of the service account.")], - key_id: Annotated[StrictStr, Field(description="ID of the key.")], + key_id: Annotated[UUID, Field(description="ID of the key.")], partial_update_service_account_key_payload: Annotated[ Optional[PartialUpdateServiceAccountKeyPayload], Field(description="Service account request") ] = None, @@ -4488,7 +4489,7 @@ def partial_update_service_account_key_with_http_info( :param service_account_email: The email of the service account. (required) :type service_account_email: str :param key_id: ID of the key. (required) - :type key_id: str + :type key_id: UUID :param partial_update_service_account_key_payload: Service account request :type partial_update_service_account_key_payload: PartialUpdateServiceAccountKeyPayload :param _request_timeout: timeout setting for this request. If one @@ -4543,7 +4544,7 @@ def partial_update_service_account_key_without_preload_content( self, project_id: Annotated[StrictStr, Field(description="The ID of the project.")], service_account_email: Annotated[StrictStr, Field(description="The email of the service account.")], - key_id: Annotated[StrictStr, Field(description="ID of the key.")], + key_id: Annotated[UUID, Field(description="ID of the key.")], partial_update_service_account_key_payload: Annotated[ Optional[PartialUpdateServiceAccountKeyPayload], Field(description="Service account request") ] = None, @@ -4566,7 +4567,7 @@ def partial_update_service_account_key_without_preload_content( :param service_account_email: The email of the service account. (required) :type service_account_email: str :param key_id: ID of the key. (required) - :type key_id: str + :type key_id: UUID :param partial_update_service_account_key_payload: Service account request :type partial_update_service_account_key_payload: PartialUpdateServiceAccountKeyPayload :param _request_timeout: timeout setting for this request. If one diff --git a/services/serviceaccount/src/stackit/serviceaccount/api_client.py b/services/serviceaccount/src/stackit/serviceaccount/api_client.py index f62db580..bd8a84c7 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/api_client.py +++ b/services/serviceaccount/src/stackit/serviceaccount/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")): # noqa: B009 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/serviceaccount/src/stackit/serviceaccount/exceptions.py b/services/serviceaccount/src/stackit/serviceaccount/exceptions.py index 737982c0..2e9c0269 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/exceptions.py +++ b/services/serviceaccount/src/stackit/serviceaccount/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/serviceaccount/src/stackit/serviceaccount/models/__init__.py b/services/serviceaccount/src/stackit/serviceaccount/models/__init__.py index 96d72b3d..b1a0e99a 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/__init__.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/__init__.py @@ -12,7 +12,6 @@ Do not edit the class manually. """ # noqa: E501 - # import models into model package from stackit.serviceaccount.models.access_token import AccessToken from stackit.serviceaccount.models.access_token_metadata import AccessTokenMetadata diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/access_token.py b/services/serviceaccount/src/stackit/serviceaccount/models/access_token.py index 7bb265cc..92d23975 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/access_token.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/access_token.py @@ -18,6 +18,7 @@ import re # noqa: F401 from datetime import datetime from typing import Any, ClassVar, Dict, List, Optional, Set +from uuid import UUID from pydantic import ( BaseModel, @@ -37,7 +38,7 @@ class AccessToken(BaseModel): active: StrictBool = Field(description="Newly created access tokens are valid, and can be revoked if needed.") created_at: datetime = Field(description="Creation time of the access token.", alias="createdAt") - id: StrictStr = Field(description="Unique ID of the access token. Also used as JTI field.") + id: UUID = Field(description="Unique ID of the access token. Also used as JTI field.") token: StrictStr = Field( description="The access token in JWT format. Use this with `Bearer` prefix for API calls. Store it, as it is not recoverable later." ) diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/access_token_metadata.py b/services/serviceaccount/src/stackit/serviceaccount/models/access_token_metadata.py index b3bd0779..a1f84fec 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/access_token_metadata.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/access_token_metadata.py @@ -18,15 +18,9 @@ import re # noqa: F401 from datetime import datetime from typing import Any, ClassVar, Dict, List, Optional, Set +from uuid import UUID -from pydantic import ( - BaseModel, - ConfigDict, - Field, - StrictBool, - StrictStr, - field_validator, -) +from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator from typing_extensions import Self @@ -39,7 +33,7 @@ class AccessTokenMetadata(BaseModel): description="If true, access token can be used for authorized API calls, if false, the token is not usable anymore." ) created_at: datetime = Field(description="Creation time of the access token.", alias="createdAt") - id: StrictStr = Field(description="Unique ID of the access token. Also used as JTI field.") + id: UUID = Field(description="Unique ID of the access token. Also used as JTI field.") valid_until: datetime = Field( description="Approximate expiration time of the access token. Check the JWT for actual validity date.", alias="validUntil", diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/create_federated_identity_provider_payload.py b/services/serviceaccount/src/stackit/serviceaccount/models/create_federated_identity_provider_payload.py index 7aa7aba9..0c8a9812 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/create_federated_identity_provider_payload.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/create_federated_identity_provider_payload.py @@ -77,9 +77,9 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of each item in assertions (list) _items = [] if self.assertions: - for _item in self.assertions: - if _item: - _items.append(_item.to_dict()) + for _item_assertions in self.assertions: + if _item_assertions: + _items.append(_item_assertions.to_dict()) _dict["assertions"] = _items return _dict diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/create_service_account_key_response.py b/services/serviceaccount/src/stackit/serviceaccount/models/create_service_account_key_response.py index 72b1998f..721d3fcd 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/create_service_account_key_response.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/create_service_account_key_response.py @@ -18,6 +18,7 @@ import re # noqa: F401 from datetime import datetime from typing import Any, ClassVar, Dict, List, Optional, Set +from uuid import UUID from pydantic import ( BaseModel, @@ -42,7 +43,7 @@ class CreateServiceAccountKeyResponse(BaseModel): active: StrictBool created_at: datetime = Field(description="Creation time of the key", alias="createdAt") credentials: CreateServiceAccountKeyResponseCredentials - id: StrictStr = Field(description="Unique ID of the key.") + id: UUID = Field(description="Unique ID of the key.") key_algorithm: StrictStr = Field(alias="keyAlgorithm") key_origin: StrictStr = Field(alias="keyOrigin") key_type: StrictStr = Field(alias="keyType") diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/create_service_account_key_response_credentials.py b/services/serviceaccount/src/stackit/serviceaccount/models/create_service_account_key_response_credentials.py index 2d9b3c78..c45f334f 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/create_service_account_key_response_credentials.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/create_service_account_key_response_credentials.py @@ -16,6 +16,7 @@ import json import pprint from typing import Any, ClassVar, Dict, List, Optional, Set +from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing_extensions import Self @@ -34,7 +35,7 @@ class CreateServiceAccountKeyResponseCredentials(BaseModel): description="Private key. Only present, if the service account API was generating the key. Not recoverable later.", alias="privateKey", ) - sub: StrictStr = Field(description="Service account id") + sub: UUID = Field(description="Service account id") __properties: ClassVar[List[str]] = ["aud", "iss", "kid", "privateKey", "sub"] model_config = ConfigDict( diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/federated_identity_provider.py b/services/serviceaccount/src/stackit/serviceaccount/models/federated_identity_provider.py index 72e55ddd..ee45248f 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/federated_identity_provider.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/federated_identity_provider.py @@ -18,6 +18,7 @@ import re # noqa: F401 from datetime import datetime from typing import Any, ClassVar, Dict, List, Optional, Set +from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator from typing_extensions import Self @@ -36,7 +37,7 @@ class FederatedIdentityProvider(BaseModel): description="list of assertions of the federated identity provider" ) created_at: datetime = Field(description="Creation time of the federated identity provider.", alias="createdAt") - id: Optional[StrictStr] = Field(default=None, description="Unique ID of the federated identity provider.") + id: Optional[UUID] = Field(default=None, description="Unique ID of the federated identity provider.") issuer: StrictStr = Field(description="Issuer of the federated identity provider.") name: StrictStr = Field(description="Unique name of the federated identity provider.") updated_at: datetime = Field(description="Last update time of the federated identity provider.", alias="updatedAt") @@ -108,9 +109,9 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of each item in assertions (list) _items = [] if self.assertions: - for _item in self.assertions: - if _item: - _items.append(_item.to_dict()) + for _item_assertions in self.assertions: + if _item_assertions: + _items.append(_item_assertions.to_dict()) _dict["assertions"] = _items return _dict diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/federated_list_federated_identity_providers_response.py b/services/serviceaccount/src/stackit/serviceaccount/models/federated_list_federated_identity_providers_response.py index 79e01d62..7a7b8f82 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/federated_list_federated_identity_providers_response.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/federated_list_federated_identity_providers_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 resources (list) _items = [] if self.resources: - for _item in self.resources: - if _item: - _items.append(_item.to_dict()) + for _item_resources in self.resources: + if _item_resources: + _items.append(_item_resources.to_dict()) _dict["resources"] = _items return _dict diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/get_service_account_key_response.py b/services/serviceaccount/src/stackit/serviceaccount/models/get_service_account_key_response.py index bcd33a0f..75dbc0cc 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/get_service_account_key_response.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/get_service_account_key_response.py @@ -18,6 +18,7 @@ import re # noqa: F401 from datetime import datetime from typing import Any, ClassVar, Dict, List, Optional, Set +from uuid import UUID from pydantic import ( BaseModel, @@ -42,7 +43,7 @@ class GetServiceAccountKeyResponse(BaseModel): active: StrictBool created_at: datetime = Field(description="Creation time of the key", alias="createdAt") credentials: GetServiceAccountKeyResponseCredentials - id: StrictStr = Field(description="Unique ID of the key.") + id: UUID = Field(description="Unique ID of the key.") key_algorithm: StrictStr = Field(alias="keyAlgorithm") key_origin: StrictStr = Field(alias="keyOrigin") key_type: StrictStr = Field(alias="keyType") diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/get_service_account_key_response_credentials.py b/services/serviceaccount/src/stackit/serviceaccount/models/get_service_account_key_response_credentials.py index 7748c5d0..d91e3a27 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/get_service_account_key_response_credentials.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/get_service_account_key_response_credentials.py @@ -16,6 +16,7 @@ import json import pprint from typing import Any, ClassVar, Dict, List, Optional, Set +from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing_extensions import Self @@ -29,7 +30,7 @@ class GetServiceAccountKeyResponseCredentials(BaseModel): aud: StrictStr = Field(description="Audience - service account API URL") iss: StrictStr = Field(description="Service account email") kid: StrictStr = Field(description="Key id to use") - sub: StrictStr = Field(description="Service account id") + sub: UUID = Field(description="Service account id") __properties: ClassVar[List[str]] = ["aud", "iss", "kid", "sub"] model_config = ConfigDict( diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/jwks.py b/services/serviceaccount/src/stackit/serviceaccount/models/jwks.py index 312fad5f..fefee4c2 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/jwks.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/jwks.py @@ -71,9 +71,9 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of each item in keys (list) _items = [] if self.keys: - for _item in self.keys: - if _item: - _items.append(_item.to_dict()) + for _item_keys in self.keys: + if _item_keys: + _items.append(_item_keys.to_dict()) _dict["keys"] = _items return _dict diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/list_access_tokens_response.py b/services/serviceaccount/src/stackit/serviceaccount/models/list_access_tokens_response.py index 8ebd0ec3..1878d4ef 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/list_access_tokens_response.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/list_access_tokens_response.py @@ -71,9 +71,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/serviceaccount/src/stackit/serviceaccount/models/list_service_account_keys_response.py b/services/serviceaccount/src/stackit/serviceaccount/models/list_service_account_keys_response.py index 92730a02..4f1f6e4f 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/list_service_account_keys_response.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/list_service_account_keys_response.py @@ -73,9 +73,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/serviceaccount/src/stackit/serviceaccount/models/list_service_accounts_response.py b/services/serviceaccount/src/stackit/serviceaccount/models/list_service_accounts_response.py index 78865960..813b6e43 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/list_service_accounts_response.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/list_service_accounts_response.py @@ -71,9 +71,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/serviceaccount/src/stackit/serviceaccount/models/partial_update_service_account_federated_identity_provider_payload.py b/services/serviceaccount/src/stackit/serviceaccount/models/partial_update_service_account_federated_identity_provider_payload.py index 42cf9154..5724d993 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/partial_update_service_account_federated_identity_provider_payload.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/partial_update_service_account_federated_identity_provider_payload.py @@ -77,9 +77,9 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of each item in assertions (list) _items = [] if self.assertions: - for _item in self.assertions: - if _item: - _items.append(_item.to_dict()) + for _item_assertions in self.assertions: + if _item_assertions: + _items.append(_item_assertions.to_dict()) _dict["assertions"] = _items return _dict diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/partial_update_service_account_key_response.py b/services/serviceaccount/src/stackit/serviceaccount/models/partial_update_service_account_key_response.py index cf6c64f6..4404e3cc 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/partial_update_service_account_key_response.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/partial_update_service_account_key_response.py @@ -18,6 +18,7 @@ import re # noqa: F401 from datetime import datetime from typing import Any, ClassVar, Dict, List, Optional, Set +from uuid import UUID from pydantic import ( BaseModel, @@ -37,7 +38,7 @@ class PartialUpdateServiceAccountKeyResponse(BaseModel): active: StrictBool created_at: datetime = Field(description="Creation time of the key", alias="createdAt") - id: StrictStr = Field(description="Unique ID of the key.") + id: UUID = Field(description="Unique ID of the key.") key_algorithm: StrictStr = Field(alias="keyAlgorithm") key_origin: StrictStr = Field(alias="keyOrigin") key_type: StrictStr = Field(alias="keyType") diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/service_account.py b/services/serviceaccount/src/stackit/serviceaccount/models/service_account.py index ee257b1b..7cb10be4 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/service_account.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/service_account.py @@ -16,6 +16,7 @@ import json import pprint from typing import Any, ClassVar, Dict, List, Optional, Set +from uuid import UUID from pydantic import ( BaseModel, @@ -35,7 +36,7 @@ class ServiceAccount(BaseModel): email: StrictStr = Field( description="Unique identifier of the service account in format of an email address generated by the service containing the prefix provided by the user during creation." ) - id: StrictStr = Field( + id: UUID = Field( description="Unique ID of the service account. It is also used in the 'sub' field of the service accounts access tokens." ) internal: StrictBool = Field(description="Flag indicating internal service accounts") diff --git a/services/serviceaccount/src/stackit/serviceaccount/models/service_account_key_list_response.py b/services/serviceaccount/src/stackit/serviceaccount/models/service_account_key_list_response.py index 257d6b48..bec11a19 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/models/service_account_key_list_response.py +++ b/services/serviceaccount/src/stackit/serviceaccount/models/service_account_key_list_response.py @@ -18,6 +18,7 @@ import re # noqa: F401 from datetime import datetime from typing import Any, ClassVar, Dict, List, Optional, Set +from uuid import UUID from pydantic import ( BaseModel, @@ -37,7 +38,7 @@ class ServiceAccountKeyListResponse(BaseModel): active: StrictBool created_at: datetime = Field(description="Creation time of the key", alias="createdAt") - id: StrictStr = Field(description="Unique ID of the key.") + id: UUID = Field(description="Unique ID of the key.") key_algorithm: StrictStr = Field(alias="keyAlgorithm") key_origin: StrictStr = Field(alias="keyOrigin") key_type: StrictStr = Field(alias="keyType") diff --git a/services/serviceaccount/src/stackit/serviceaccount/rest.py b/services/serviceaccount/src/stackit/serviceaccount/rest.py index 36442489..e66e383b 100644 --- a/services/serviceaccount/src/stackit/serviceaccount/rest.py +++ b/services/serviceaccount/src/stackit/serviceaccount/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)]) diff --git a/services/serviceaccount/uv.lock b/services/serviceaccount/uv.lock index 4405c981..86f5da0c 100644 --- a/services/serviceaccount/uv.lock +++ b/services/serviceaccount/uv.lock @@ -907,7 +907,7 @@ dev = [ [[package]] name = "stackit-serviceaccount" -version = "0.5.0" +version = "0.6.0" source = { editable = "." } dependencies = [ { name = "pydantic" },