Skip to content
Open
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
2 changes: 1 addition & 1 deletion services/loadbalancer/oas_commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10774896634990c655a523f5f0fabd6e2be9e216
0e64886dd0847341800d7191ed193b75413be998
25 changes: 13 additions & 12 deletions services/loadbalancer/src/stackit/loadbalancer/api/default_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
""" # noqa: E501

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
Expand Down Expand Up @@ -73,7 +74,7 @@ def create_credentials(
project_id: StrictStr,
region: StrictStr,
create_credentials_payload: CreateCredentialsPayload,
x_request_id: Optional[StrictStr] = None,
x_request_id: Optional[UUID] = None,
_request_timeout: Union[
None,
Annotated[StrictFloat, Field(gt=0)],
Expand All @@ -95,7 +96,7 @@ def create_credentials(
:param create_credentials_payload: (required)
:type create_credentials_payload: CreateCredentialsPayload
:param x_request_id:
:type x_request_id: str
:type x_request_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
Expand Down Expand Up @@ -149,7 +150,7 @@ def create_credentials_with_http_info(
project_id: StrictStr,
region: StrictStr,
create_credentials_payload: CreateCredentialsPayload,
x_request_id: Optional[StrictStr] = None,
x_request_id: Optional[UUID] = None,
_request_timeout: Union[
None,
Annotated[StrictFloat, Field(gt=0)],
Expand All @@ -171,7 +172,7 @@ def create_credentials_with_http_info(
:param create_credentials_payload: (required)
:type create_credentials_payload: CreateCredentialsPayload
:param x_request_id:
:type x_request_id: str
:type x_request_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
Expand Down Expand Up @@ -225,7 +226,7 @@ def create_credentials_without_preload_content(
project_id: StrictStr,
region: StrictStr,
create_credentials_payload: CreateCredentialsPayload,
x_request_id: Optional[StrictStr] = None,
x_request_id: Optional[UUID] = None,
_request_timeout: Union[
None,
Annotated[StrictFloat, Field(gt=0)],
Expand All @@ -247,7 +248,7 @@ def create_credentials_without_preload_content(
:param create_credentials_payload: (required)
:type create_credentials_payload: CreateCredentialsPayload
:param x_request_id:
:type x_request_id: str
:type x_request_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
Expand Down Expand Up @@ -364,7 +365,7 @@ def create_load_balancer(
project_id: StrictStr,
region: StrictStr,
create_load_balancer_payload: CreateLoadBalancerPayload,
x_request_id: Optional[StrictStr] = None,
x_request_id: Optional[UUID] = None,
_request_timeout: Union[
None,
Annotated[StrictFloat, Field(gt=0)],
Expand All @@ -386,7 +387,7 @@ def create_load_balancer(
:param create_load_balancer_payload: (required)
:type create_load_balancer_payload: CreateLoadBalancerPayload
:param x_request_id:
:type x_request_id: str
:type x_request_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
Expand Down Expand Up @@ -441,7 +442,7 @@ def create_load_balancer_with_http_info(
project_id: StrictStr,
region: StrictStr,
create_load_balancer_payload: CreateLoadBalancerPayload,
x_request_id: Optional[StrictStr] = None,
x_request_id: Optional[UUID] = None,
_request_timeout: Union[
None,
Annotated[StrictFloat, Field(gt=0)],
Expand All @@ -463,7 +464,7 @@ def create_load_balancer_with_http_info(
:param create_load_balancer_payload: (required)
:type create_load_balancer_payload: CreateLoadBalancerPayload
:param x_request_id:
:type x_request_id: str
:type x_request_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
Expand Down Expand Up @@ -518,7 +519,7 @@ def create_load_balancer_without_preload_content(
project_id: StrictStr,
region: StrictStr,
create_load_balancer_payload: CreateLoadBalancerPayload,
x_request_id: Optional[StrictStr] = None,
x_request_id: Optional[UUID] = None,
_request_timeout: Union[
None,
Annotated[StrictFloat, Field(gt=0)],
Expand All @@ -540,7 +541,7 @@ def create_load_balancer_without_preload_content(
:param create_load_balancer_payload: (required)
:type create_load_balancer_payload: CreateLoadBalancerPayload
:param x_request_id:
:type x_request_id: str
:type x_request_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
Expand Down
31 changes: 22 additions & 9 deletions services/loadbalancer/src/stackit/loadbalancer/api_client.py
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")): # noqa: B009
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.loadbalancer.models.active_health_check import ActiveHealthCheck
from stackit.loadbalancer.models.create_credentials_payload import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,36 +199,36 @@ def to_dict(self) -> Dict[str, Any]:
# override the default output from pydantic by calling `to_dict()` of each item in errors (list)
_items = []
if self.errors:
for _item in self.errors:
if _item:
_items.append(_item.to_dict())
for _item_errors in self.errors:
if _item_errors:
_items.append(_item_errors.to_dict())
_dict["errors"] = _items
# override the default output from pydantic by calling `to_dict()` of each item in listeners (list)
_items = []
if self.listeners:
for _item in self.listeners:
if _item:
_items.append(_item.to_dict())
for _item_listeners in self.listeners:
if _item_listeners:
_items.append(_item_listeners.to_dict())
_dict["listeners"] = _items
# override the default output from pydantic by calling `to_dict()` of load_balancer_security_group
if self.load_balancer_security_group:
_dict["loadBalancerSecurityGroup"] = self.load_balancer_security_group.to_dict()
# override the default output from pydantic by calling `to_dict()` of each item in networks (list)
_items = []
if self.networks:
for _item in self.networks:
if _item:
_items.append(_item.to_dict())
for _item_networks in self.networks:
if _item_networks:
_items.append(_item_networks.to_dict())
_dict["networks"] = _items
# override the default output from pydantic by calling `to_dict()` of options
if self.options:
_dict["options"] = self.options.to_dict()
# override the default output from pydantic by calling `to_dict()` of each item in target_pools (list)
_items = []
if self.target_pools:
for _item in self.target_pools:
if _item:
_items.append(_item.to_dict())
for _item_target_pools in self.target_pools:
if _item_target_pools:
_items.append(_item_target_pools.to_dict())
_dict["targetPools"] = _items
# override the default output from pydantic by calling `to_dict()` of target_security_group
if self.target_security_group:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import pprint
import re # noqa: F401
from typing import Any, ClassVar, Dict, List, Optional, Set
from uuid import UUID

from pydantic import BaseModel, ConfigDict, Field, field_validator
from typing_extensions import Annotated, Self
Expand All @@ -37,9 +38,7 @@ class GetQuotaResponse(BaseModel):
description="The maximum number of load balancing servers in this project. Unlimited if set to -1.",
alias="maxLoadBalancers",
)
project_id: Optional[Annotated[str, Field(strict=True)]] = Field(
default=None, description="Project identifier", alias="projectId"
)
project_id: Optional[UUID] = Field(default=None, description="Project identifier", alias="projectId")
region: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="Region")
used_credentials: Optional[Annotated[int, Field(le=1000000, strict=True, ge=-1)]] = Field(
default=None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 credentials (list)
_items = []
if self.credentials:
for _item in self.credentials:
if _item:
_items.append(_item.to_dict())
for _item_credentials in self.credentials:
if _item_credentials:
_items.append(_item_credentials.to_dict())
_dict["credentials"] = _items
return _dict

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 valid_plans (list)
_items = []
if self.valid_plans:
for _item in self.valid_plans:
if _item:
_items.append(_item.to_dict())
for _item_valid_plans in self.valid_plans:
if _item_valid_plans:
_items.append(_item_valid_plans.to_dict())
_dict["validPlans"] = _items
return _dict

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