Skip to content

Commit 9475828

Browse files
Generate serverbackup (#407)
1 parent ee1814a commit 9475828

File tree

6 files changed

+535
-0
lines changed

6 files changed

+535
-0
lines changed

services/serverbackup/src/stackit/serverbackup/__init__.py

+7
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
# import models into sdk package
3737
from stackit.serverbackup.models.backup import Backup
3838
from stackit.serverbackup.models.backup_job import BackupJob
39+
from stackit.serverbackup.models.backup_policy import BackupPolicy
40+
from stackit.serverbackup.models.backup_policy_backup_properties import (
41+
BackupPolicyBackupProperties,
42+
)
3943
from stackit.serverbackup.models.backup_properties import BackupProperties
4044
from stackit.serverbackup.models.backup_schedule import BackupSchedule
4145
from stackit.serverbackup.models.backup_volume_backups_inner import (
@@ -49,6 +53,9 @@
4953
from stackit.serverbackup.models.enable_service_resource_payload import (
5054
EnableServiceResourcePayload,
5155
)
56+
from stackit.serverbackup.models.get_backup_policies_response import (
57+
GetBackupPoliciesResponse,
58+
)
5259
from stackit.serverbackup.models.get_backup_schedules_response import (
5360
GetBackupSchedulesResponse,
5461
)

services/serverbackup/src/stackit/serverbackup/api/default_api.py

+232
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
from stackit.serverbackup.models.enable_service_resource_payload import (
3333
EnableServiceResourcePayload,
3434
)
35+
from stackit.serverbackup.models.get_backup_policies_response import (
36+
GetBackupPoliciesResponse,
37+
)
3538
from stackit.serverbackup.models.get_backup_schedules_response import (
3639
GetBackupSchedulesResponse,
3740
)
@@ -2888,6 +2891,235 @@ def _get_backup_schedule_serialize(
28882891
_request_auth=_request_auth,
28892892
)
28902893

2894+
@validate_call
2895+
def list_backup_policies(
2896+
self,
2897+
project_id: Annotated[StrictStr, Field(description="project id")],
2898+
_request_timeout: Union[
2899+
None,
2900+
Annotated[StrictFloat, Field(gt=0)],
2901+
Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]],
2902+
] = None,
2903+
_request_auth: Optional[Dict[StrictStr, Any]] = None,
2904+
_content_type: Optional[StrictStr] = None,
2905+
_headers: Optional[Dict[StrictStr, Any]] = None,
2906+
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
2907+
) -> GetBackupPoliciesResponse:
2908+
"""get list of backup policies
2909+
2910+
2911+
:param project_id: project id (required)
2912+
:type project_id: str
2913+
:param _request_timeout: timeout setting for this request. If one
2914+
number provided, it will be total request
2915+
timeout. It can also be a pair (tuple) of
2916+
(connection, read) timeouts.
2917+
:type _request_timeout: int, tuple(int, int), optional
2918+
:param _request_auth: set to override the auth_settings for an a single
2919+
request; this effectively ignores the
2920+
authentication in the spec for a single request.
2921+
:type _request_auth: dict, optional
2922+
:param _content_type: force content-type for the request.
2923+
:type _content_type: str, Optional
2924+
:param _headers: set to override the headers for a single
2925+
request; this effectively ignores the headers
2926+
in the spec for a single request.
2927+
:type _headers: dict, optional
2928+
:param _host_index: set to override the host_index for a single
2929+
request; this effectively ignores the host_index
2930+
in the spec for a single request.
2931+
:type _host_index: int, optional
2932+
:return: Returns the result object.
2933+
""" # noqa: E501 docstring might be too long
2934+
2935+
_param = self._list_backup_policies_serialize(
2936+
project_id=project_id,
2937+
_request_auth=_request_auth,
2938+
_content_type=_content_type,
2939+
_headers=_headers,
2940+
_host_index=_host_index,
2941+
)
2942+
2943+
_response_types_map: Dict[str, Optional[str]] = {
2944+
"200": "GetBackupPoliciesResponse",
2945+
"400": None,
2946+
"404": None,
2947+
}
2948+
response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)
2949+
response_data.read()
2950+
return self.api_client.response_deserialize(
2951+
response_data=response_data,
2952+
response_types_map=_response_types_map,
2953+
).data
2954+
2955+
@validate_call
2956+
def list_backup_policies_with_http_info(
2957+
self,
2958+
project_id: Annotated[StrictStr, Field(description="project id")],
2959+
_request_timeout: Union[
2960+
None,
2961+
Annotated[StrictFloat, Field(gt=0)],
2962+
Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]],
2963+
] = None,
2964+
_request_auth: Optional[Dict[StrictStr, Any]] = None,
2965+
_content_type: Optional[StrictStr] = None,
2966+
_headers: Optional[Dict[StrictStr, Any]] = None,
2967+
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
2968+
) -> ApiResponse[GetBackupPoliciesResponse]:
2969+
"""get list of backup policies
2970+
2971+
2972+
:param project_id: project id (required)
2973+
:type project_id: str
2974+
:param _request_timeout: timeout setting for this request. If one
2975+
number provided, it will be total request
2976+
timeout. It can also be a pair (tuple) of
2977+
(connection, read) timeouts.
2978+
:type _request_timeout: int, tuple(int, int), optional
2979+
:param _request_auth: set to override the auth_settings for an a single
2980+
request; this effectively ignores the
2981+
authentication in the spec for a single request.
2982+
:type _request_auth: dict, optional
2983+
:param _content_type: force content-type for the request.
2984+
:type _content_type: str, Optional
2985+
:param _headers: set to override the headers for a single
2986+
request; this effectively ignores the headers
2987+
in the spec for a single request.
2988+
:type _headers: dict, optional
2989+
:param _host_index: set to override the host_index for a single
2990+
request; this effectively ignores the host_index
2991+
in the spec for a single request.
2992+
:type _host_index: int, optional
2993+
:return: Returns the result object.
2994+
""" # noqa: E501 docstring might be too long
2995+
2996+
_param = self._list_backup_policies_serialize(
2997+
project_id=project_id,
2998+
_request_auth=_request_auth,
2999+
_content_type=_content_type,
3000+
_headers=_headers,
3001+
_host_index=_host_index,
3002+
)
3003+
3004+
_response_types_map: Dict[str, Optional[str]] = {
3005+
"200": "GetBackupPoliciesResponse",
3006+
"400": None,
3007+
"404": None,
3008+
}
3009+
response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)
3010+
response_data.read()
3011+
return self.api_client.response_deserialize(
3012+
response_data=response_data,
3013+
response_types_map=_response_types_map,
3014+
)
3015+
3016+
@validate_call
3017+
def list_backup_policies_without_preload_content(
3018+
self,
3019+
project_id: Annotated[StrictStr, Field(description="project id")],
3020+
_request_timeout: Union[
3021+
None,
3022+
Annotated[StrictFloat, Field(gt=0)],
3023+
Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]],
3024+
] = None,
3025+
_request_auth: Optional[Dict[StrictStr, Any]] = None,
3026+
_content_type: Optional[StrictStr] = None,
3027+
_headers: Optional[Dict[StrictStr, Any]] = None,
3028+
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
3029+
) -> RESTResponseType:
3030+
"""get list of backup policies
3031+
3032+
3033+
:param project_id: project id (required)
3034+
:type project_id: str
3035+
:param _request_timeout: timeout setting for this request. If one
3036+
number provided, it will be total request
3037+
timeout. It can also be a pair (tuple) of
3038+
(connection, read) timeouts.
3039+
:type _request_timeout: int, tuple(int, int), optional
3040+
:param _request_auth: set to override the auth_settings for an a single
3041+
request; this effectively ignores the
3042+
authentication in the spec for a single request.
3043+
:type _request_auth: dict, optional
3044+
:param _content_type: force content-type for the request.
3045+
:type _content_type: str, Optional
3046+
:param _headers: set to override the headers for a single
3047+
request; this effectively ignores the headers
3048+
in the spec for a single request.
3049+
:type _headers: dict, optional
3050+
:param _host_index: set to override the host_index for a single
3051+
request; this effectively ignores the host_index
3052+
in the spec for a single request.
3053+
:type _host_index: int, optional
3054+
:return: Returns the result object.
3055+
""" # noqa: E501 docstring might be too long
3056+
3057+
_param = self._list_backup_policies_serialize(
3058+
project_id=project_id,
3059+
_request_auth=_request_auth,
3060+
_content_type=_content_type,
3061+
_headers=_headers,
3062+
_host_index=_host_index,
3063+
)
3064+
3065+
_response_types_map: Dict[str, Optional[str]] = {
3066+
"200": "GetBackupPoliciesResponse",
3067+
"400": None,
3068+
"404": None,
3069+
}
3070+
response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)
3071+
return response_data.response
3072+
3073+
def _list_backup_policies_serialize(
3074+
self,
3075+
project_id,
3076+
_request_auth,
3077+
_content_type,
3078+
_headers,
3079+
_host_index,
3080+
) -> RequestSerialized:
3081+
3082+
_host = None
3083+
3084+
_collection_formats: Dict[str, str] = {}
3085+
3086+
_path_params: Dict[str, str] = {}
3087+
_query_params: List[Tuple[str, str]] = []
3088+
_header_params: Dict[str, Optional[str]] = _headers or {}
3089+
_form_params: List[Tuple[str, str]] = []
3090+
_files: Dict[str, Union[str, bytes]] = {}
3091+
_body_params: Optional[bytes] = None
3092+
3093+
# process the path parameters
3094+
if project_id is not None:
3095+
_path_params["projectId"] = project_id
3096+
# process the query parameters
3097+
# process the header parameters
3098+
# process the form parameters
3099+
# process the body parameter
3100+
3101+
# set the HTTP header `Accept`
3102+
if "Accept" not in _header_params:
3103+
_header_params["Accept"] = self.api_client.select_header_accept(["application/json"])
3104+
3105+
# authentication setting
3106+
_auth_settings: List[str] = []
3107+
3108+
return self.api_client.param_serialize(
3109+
method="GET",
3110+
resource_path="/v1/projects/{projectId}/backup-policies",
3111+
path_params=_path_params,
3112+
query_params=_query_params,
3113+
header_params=_header_params,
3114+
body=_body_params,
3115+
post_params=_form_params,
3116+
files=_files,
3117+
auth_settings=_auth_settings,
3118+
collection_formats=_collection_formats,
3119+
_host=_host,
3120+
_request_auth=_request_auth,
3121+
)
3122+
28913123
@validate_call
28923124
def list_backup_schedules(
28933125
self,

services/serverbackup/src/stackit/serverbackup/models/__init__.py

+7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
# import models into model package
1818
from stackit.serverbackup.models.backup import Backup
1919
from stackit.serverbackup.models.backup_job import BackupJob
20+
from stackit.serverbackup.models.backup_policy import BackupPolicy
21+
from stackit.serverbackup.models.backup_policy_backup_properties import (
22+
BackupPolicyBackupProperties,
23+
)
2024
from stackit.serverbackup.models.backup_properties import BackupProperties
2125
from stackit.serverbackup.models.backup_schedule import BackupSchedule
2226
from stackit.serverbackup.models.backup_volume_backups_inner import (
@@ -30,6 +34,9 @@
3034
from stackit.serverbackup.models.enable_service_resource_payload import (
3135
EnableServiceResourcePayload,
3236
)
37+
from stackit.serverbackup.models.get_backup_policies_response import (
38+
GetBackupPoliciesResponse,
39+
)
3340
from stackit.serverbackup.models.get_backup_schedules_response import (
3441
GetBackupSchedulesResponse,
3542
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# coding: utf-8
2+
3+
"""
4+
STACKIT Server Backup Management API
5+
6+
API endpoints for Server Backup Operations on STACKIT Servers.
7+
8+
The version of the OpenAPI document: 1.0
9+
Contact: support@stackit.de
10+
Generated by OpenAPI Generator (https://openapi-generator.tech)
11+
12+
Do not edit the class manually.
13+
""" # noqa: E501 docstring might be too long
14+
15+
from __future__ import annotations
16+
17+
import json
18+
import pprint
19+
from typing import Any, ClassVar, Dict, List, Optional, Set
20+
21+
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
22+
from typing_extensions import Self
23+
24+
from stackit.serverbackup.models.backup_policy_backup_properties import (
25+
BackupPolicyBackupProperties,
26+
)
27+
28+
29+
class BackupPolicy(BaseModel):
30+
"""
31+
BackupPolicy
32+
"""
33+
34+
backup_properties: Optional[BackupPolicyBackupProperties] = Field(default=None, alias="backupProperties")
35+
default: Optional[StrictBool] = None
36+
description: Optional[StrictStr] = None
37+
enabled: Optional[StrictBool] = None
38+
id: Optional[StrictStr] = None
39+
name: Optional[StrictStr] = None
40+
rrule: Optional[StrictStr] = None
41+
__properties: ClassVar[List[str]] = ["backupProperties", "default", "description", "enabled", "id", "name", "rrule"]
42+
43+
model_config = ConfigDict(
44+
populate_by_name=True,
45+
validate_assignment=True,
46+
protected_namespaces=(),
47+
)
48+
49+
def to_str(self) -> str:
50+
"""Returns the string representation of the model using alias"""
51+
return pprint.pformat(self.model_dump(by_alias=True))
52+
53+
def to_json(self) -> str:
54+
"""Returns the JSON representation of the model using alias"""
55+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
56+
return json.dumps(self.to_dict())
57+
58+
@classmethod
59+
def from_json(cls, json_str: str) -> Optional[Self]:
60+
"""Create an instance of BackupPolicy from a JSON string"""
61+
return cls.from_dict(json.loads(json_str))
62+
63+
def to_dict(self) -> Dict[str, Any]:
64+
"""Return the dictionary representation of the model using alias.
65+
66+
This has the following differences from calling pydantic's
67+
`self.model_dump(by_alias=True)`:
68+
69+
* `None` is only added to the output dict for nullable fields that
70+
were set at model initialization. Other fields with value `None`
71+
are ignored.
72+
"""
73+
excluded_fields: Set[str] = set([])
74+
75+
_dict = self.model_dump(
76+
by_alias=True,
77+
exclude=excluded_fields,
78+
exclude_none=True,
79+
)
80+
# override the default output from pydantic by calling `to_dict()` of backup_properties
81+
if self.backup_properties:
82+
_dict["backupProperties"] = self.backup_properties.to_dict()
83+
return _dict
84+
85+
@classmethod
86+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
87+
"""Create an instance of BackupPolicy from a dict"""
88+
if obj is None:
89+
return None
90+
91+
if not isinstance(obj, dict):
92+
return cls.model_validate(obj)
93+
94+
_obj = cls.model_validate(
95+
{
96+
"backupProperties": (
97+
BackupPolicyBackupProperties.from_dict(obj["backupProperties"])
98+
if obj.get("backupProperties") is not None
99+
else None
100+
),
101+
"default": obj.get("default"),
102+
"description": obj.get("description"),
103+
"enabled": obj.get("enabled"),
104+
"id": obj.get("id"),
105+
"name": obj.get("name"),
106+
"rrule": obj.get("rrule"),
107+
}
108+
)
109+
return _obj

0 commit comments

Comments
 (0)