Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions services/resourcemanager/oas_commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0e64886dd0847341800d7191ed193b75413be998
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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,
)

Expand All @@ -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.
Expand All @@ -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
Expand All @@ -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__
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
Do not edit the class manually.
""" # noqa: E501


# import models into model package
from stackit.resourcemanager.models.container_search_result import ContainerSearchResult
from stackit.resourcemanager.models.create_folder_payload import CreateFolderPayload
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, field_validator
from typing_extensions import Self
Expand All @@ -30,10 +31,10 @@ class ContainerSearchResult(BaseModel):

container_id: StrictStr = Field(description="Globally unique user-friendly identifier.", alias="containerId")
container_type: StrictStr = Field(description="Resource container type.", alias="containerType")
id: StrictStr = Field(description="Globally unique identifier.")
id: UUID = Field(description="Globally unique identifier.")
lifecycle_state: Optional[LifecycleState] = Field(default=None, alias="lifecycleState")
name: StrictStr = Field(description="Resource container name.")
organization_id: Optional[StrictStr] = Field(
organization_id: Optional[UUID] = Field(
default=None, description="Id of the organization the container is in.", alias="organizationId"
)
__properties: ClassVar[List[str]] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ def to_dict(self) -> Dict[str, Any]:
# override the default output from pydantic by calling `to_dict()` of each item in members (list)
_items = []
if self.members:
for _item in self.members:
if _item:
_items.append(_item.to_dict())
for _item_members in self.members:
if _item_members:
_items.append(_item_members.to_dict())
_dict["members"] = _items
return _dict

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ def to_dict(self) -> Dict[str, Any]:
# override the default output from pydantic by calling `to_dict()` of each item in members (list)
_items = []
if self.members:
for _item in self.members:
if _item:
_items.append(_item.to_dict())
for _item_members in self.members:
if _item_members:
_items.append(_item_members.to_dict())
_dict["members"] = _items
return _dict

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,7 +33,7 @@ class FolderResponse(BaseModel):

container_id: StrictStr = Field(description="Globally unique, user-friendly identifier.", alias="containerId")
creation_time: datetime = Field(description="Timestamp at which the folder was created.", alias="creationTime")
folder_id: StrictStr = Field(description="Globally unique folder identifier.", alias="folderId")
folder_id: UUID = Field(description="Globally unique folder identifier.", alias="folderId")
labels: Optional[Dict[str, StrictStr]] = Field(
default=None,
description="Labels are key-value string pairs that can be attached to a resource container. Some labels may be enforced via policies. - A label key must match the regex `[A-ZÄÜÖa-zäüöß0-9_-]{1,64}`. - A label value must match the regex `^$|[A-ZÄÜÖa-zäüöß0-9_-]{1,64}`.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,7 +34,7 @@ class GetFolderDetailsResponse(BaseModel):

container_id: StrictStr = Field(description="Globally unique user-friendly identifier.", alias="containerId")
creation_time: datetime = Field(description="Timestamp at which the folder was created.", alias="creationTime")
folder_id: StrictStr = Field(description="Globally unique folder identifier.", alias="folderId")
folder_id: UUID = Field(description="Globally unique folder identifier.", alias="folderId")
labels: Optional[Dict[str, StrictStr]] = Field(
default=None,
description="Labels are key-value string pairs that can be attached to a resource container. Some labels may be enforced via policies. - A label key must match the regex `[A-ZÄÜÖa-zäüöß0-9_-]{1,64}`. - A label value must match the regex `^$|[A-ZÄÜÖa-zäüöß0-9_-]{1,64}`.",
Expand Down Expand Up @@ -122,9 +123,9 @@ def to_dict(self) -> Dict[str, Any]:
# override the default output from pydantic by calling `to_dict()` of each item in parents (list)
_items = []
if self.parents:
for _item in self.parents:
if _item:
_items.append(_item.to_dict())
for _item_parents in self.parents:
if _item_parents:
_items.append(_item_parents.to_dict())
_dict["parents"] = _items
return _dict

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -42,7 +43,7 @@ class GetProjectResponse(BaseModel):
name: StrictStr = Field(description="Project name.")
parent: Parent
parents: Optional[List[ParentListInner]] = None
project_id: StrictStr = Field(description="Globally unique identifier.", alias="projectId")
project_id: UUID = Field(description="Globally unique identifier.", alias="projectId")
update_time: datetime = Field(description="Timestamp at which the project was last modified.", alias="updateTime")
__properties: ClassVar[List[str]] = [
"containerId",
Expand Down Expand Up @@ -125,9 +126,9 @@ def to_dict(self) -> Dict[str, Any]:
# override the default output from pydantic by calling `to_dict()` of each item in parents (list)
_items = []
if self.parents:
for _item in self.parents:
if _item:
_items.append(_item.to_dict())
for _item_parents in self.parents:
if _item_parents:
_items.append(_item_parents.to_dict())
_dict["parents"] = _items
return _dict

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,7 +33,7 @@ class ListFoldersResponseItemsInner(BaseModel):

container_id: StrictStr = Field(description="Globally unique folder identifier.", alias="containerId")
creation_time: datetime = Field(description="Timestamp at which the folder was created.", alias="creationTime")
folder_id: StrictStr = Field(description="Globally unique folder identifier.", alias="folderId")
folder_id: UUID = Field(description="Globally unique folder identifier.", alias="folderId")
labels: Optional[Dict[str, StrictStr]] = Field(
default=None,
description="Labels are key-value string pairs that can be attached to a resource container. Some labels may be enforced via policies. - A label key must match the regex `[A-ZÄÜÖa-zäüöß0-9_-]{1,64}`. - A label value must match the regex `^$|[A-ZÄÜÖa-zäüöß0-9_-]{1,64}`.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -40,7 +41,7 @@ class ListOrganizationsResponseItemsInner(BaseModel):
)
lifecycle_state: LifecycleState = Field(alias="lifecycleState")
name: StrictStr = Field(description="Name of the organization.")
organization_id: StrictStr = Field(description="Globally unique, organization identifier.", alias="organizationId")
organization_id: UUID = Field(description="Globally unique, organization identifier.", alias="organizationId")
update_time: datetime = Field(
description="Timestamp at which the organization was last modified.", alias="updateTime"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -40,7 +41,7 @@ class OrganizationResponse(BaseModel):
)
lifecycle_state: LifecycleState = Field(alias="lifecycleState")
name: StrictStr = Field(description="Organization name.")
organization_id: StrictStr = Field(description="Globally unique, organization identifier.", alias="organizationId")
organization_id: UUID = Field(description="Globally unique, organization identifier.", alias="organizationId")
update_time: datetime = Field(
description="Timestamp at which the organization was last modified.", alias="updateTime"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, field_validator
from typing_extensions import Self
Expand All @@ -29,7 +30,7 @@ class Parent(BaseModel):
container_id: StrictStr = Field(
description="User-friendly identifier of either organization or folder (will replace id).", alias="containerId"
)
id: StrictStr = Field(description="Identifier of either organization or folder.")
id: UUID = Field(description="Identifier of either organization or folder.")
type: StrictStr = Field(description="Container type of parent container.")
__properties: ClassVar[List[str]] = ["containerId", "id", "type"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, field_validator
from typing_extensions import Self
Expand All @@ -34,9 +35,9 @@ class ParentListInner(BaseModel):
description="User-friendly parent identifier of either organization or folder (will replace parentId).",
alias="containerParentId",
)
id: StrictStr = Field(description="Identifier.")
id: UUID = Field(description="Identifier.")
name: StrictStr = Field(description="Parent container name.")
parent_id: Optional[StrictStr] = Field(
parent_id: Optional[UUID] = Field(
default=None, description="Identifier of the parent resource container.", alias="parentId"
)
type: StrictStr = Field(description="Parent container type.")
Expand Down
Loading
Loading