Skip to content

Commit 1c3040b

Browse files
stackit-pipelinebahkauv70
authored andcommitted
Generate resourcemanager
1 parent 2a3232f commit 1c3040b

File tree

8 files changed

+1827
-39
lines changed

8 files changed

+1827
-39
lines changed

services/resourcemanager/src/stackit/resourcemanager/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,13 @@
3333
)
3434

3535
# import models into sdk package
36+
from stackit.resourcemanager.models.create_folder_payload import CreateFolderPayload
3637
from stackit.resourcemanager.models.create_project_payload import CreateProjectPayload
3738
from stackit.resourcemanager.models.error_response import ErrorResponse
39+
from stackit.resourcemanager.models.folder_response import FolderResponse
40+
from stackit.resourcemanager.models.get_folder_details_response import (
41+
GetFolderDetailsResponse,
42+
)
3843
from stackit.resourcemanager.models.get_project_response import GetProjectResponse
3944
from stackit.resourcemanager.models.lifecycle_state import LifecycleState
4045
from stackit.resourcemanager.models.list_organizations_response import (
@@ -48,6 +53,9 @@
4853
from stackit.resourcemanager.models.organization_response import OrganizationResponse
4954
from stackit.resourcemanager.models.parent import Parent
5055
from stackit.resourcemanager.models.parent_list_inner import ParentListInner
56+
from stackit.resourcemanager.models.partial_update_folder_payload import (
57+
PartialUpdateFolderPayload,
58+
)
5159
from stackit.resourcemanager.models.partial_update_project_payload import (
5260
PartialUpdateProjectPayload,
5361
)

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

Lines changed: 1331 additions & 37 deletions
Large diffs are not rendered by default.

services/resourcemanager/src/stackit/resourcemanager/configuration.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# coding: utf-8
22

3+
import sys
4+
5+
import os
6+
7+
38
"""
49
Resource Manager API
510
@@ -11,8 +16,6 @@
1116
Do not edit the class manually.
1217
""" # noqa: E501 docstring might be too long
1318

14-
import os
15-
1619

1720
class HostConfiguration:
1821
def __init__(
@@ -29,6 +32,7 @@ def __init__(
2932
"as a function argument instead of being set in the client configuration.\n"
3033
"Once all services have migrated, the methods to specify the region in the client configuration "
3134
"will be removed.",
35+
file=sys.stderr,
3236
)
3337
"""Constructor
3438
"""

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@
1414

1515

1616
# import models into model package
17+
from stackit.resourcemanager.models.create_folder_payload import CreateFolderPayload
1718
from stackit.resourcemanager.models.create_project_payload import CreateProjectPayload
1819
from stackit.resourcemanager.models.error_response import ErrorResponse
20+
from stackit.resourcemanager.models.folder_response import FolderResponse
21+
from stackit.resourcemanager.models.get_folder_details_response import (
22+
GetFolderDetailsResponse,
23+
)
1924
from stackit.resourcemanager.models.get_project_response import GetProjectResponse
2025
from stackit.resourcemanager.models.lifecycle_state import LifecycleState
2126
from stackit.resourcemanager.models.list_organizations_response import (
@@ -29,6 +34,9 @@
2934
from stackit.resourcemanager.models.organization_response import OrganizationResponse
3035
from stackit.resourcemanager.models.parent import Parent
3136
from stackit.resourcemanager.models.parent_list_inner import ParentListInner
37+
from stackit.resourcemanager.models.partial_update_folder_payload import (
38+
PartialUpdateFolderPayload,
39+
)
3240
from stackit.resourcemanager.models.partial_update_project_payload import (
3341
PartialUpdateProjectPayload,
3442
)
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# coding: utf-8
2+
3+
"""
4+
Resource Manager API
5+
6+
API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists
7+
8+
The version of the OpenAPI document: 2.0
9+
Generated by OpenAPI Generator (https://openapi-generator.tech)
10+
11+
Do not edit the class manually.
12+
""" # noqa: E501 docstring might be too long
13+
14+
from __future__ import annotations
15+
16+
import json
17+
import pprint
18+
import re
19+
from typing import Any, ClassVar, Dict, List, Optional, Set
20+
21+
from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
22+
from typing_extensions import Annotated, Self
23+
24+
from stackit.resourcemanager.models.member import Member
25+
26+
27+
class CreateFolderPayload(BaseModel):
28+
"""
29+
CreateFolderPayload
30+
"""
31+
32+
container_parent_id: StrictStr = Field(
33+
description="Identifier of the parent resource container - containerId as well as UUID identifier is supported.",
34+
alias="containerParentId",
35+
)
36+
labels: Optional[Dict[str, StrictStr]] = Field(
37+
default=None,
38+
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}`.",
39+
)
40+
members: Optional[Annotated[List[Member], Field(min_length=1)]] = Field(
41+
default=None,
42+
description="The initial members assigned to the project. At least one subject needs to be a user, and not a client or service account.",
43+
)
44+
name: Annotated[str, Field(strict=True)] = Field(
45+
description="The name of the folder matching the regex `^[a-zA-ZäüöÄÜÖ0-9]( ?[a-zA-ZäüöÄÜÖß0-9_+&-]){0,39}$`."
46+
)
47+
__properties: ClassVar[List[str]] = ["containerParentId", "labels", "members", "name"]
48+
49+
@field_validator("name")
50+
def name_validate_regular_expression(cls, value):
51+
"""Validates the regular expression"""
52+
if not re.match(r"^[a-zA-ZäüöÄÜÖ0-9]( ?[a-zA-ZäüöÄÜÖß0-9_+&-]){0,39}$", value):
53+
raise ValueError(
54+
r"must validate the regular expression /^[a-zA-ZäüöÄÜÖ0-9]( ?[a-zA-ZäüöÄÜÖß0-9_+&-]){0,39}$/"
55+
)
56+
return value
57+
58+
model_config = ConfigDict(
59+
populate_by_name=True,
60+
validate_assignment=True,
61+
protected_namespaces=(),
62+
)
63+
64+
def to_str(self) -> str:
65+
"""Returns the string representation of the model using alias"""
66+
return pprint.pformat(self.model_dump(by_alias=True))
67+
68+
def to_json(self) -> str:
69+
"""Returns the JSON representation of the model using alias"""
70+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
71+
return json.dumps(self.to_dict())
72+
73+
@classmethod
74+
def from_json(cls, json_str: str) -> Optional[Self]:
75+
"""Create an instance of CreateFolderPayload from a JSON string"""
76+
return cls.from_dict(json.loads(json_str))
77+
78+
def to_dict(self) -> Dict[str, Any]:
79+
"""Return the dictionary representation of the model using alias.
80+
81+
This has the following differences from calling pydantic's
82+
`self.model_dump(by_alias=True)`:
83+
84+
* `None` is only added to the output dict for nullable fields that
85+
were set at model initialization. Other fields with value `None`
86+
are ignored.
87+
"""
88+
excluded_fields: Set[str] = set([])
89+
90+
_dict = self.model_dump(
91+
by_alias=True,
92+
exclude=excluded_fields,
93+
exclude_none=True,
94+
)
95+
# override the default output from pydantic by calling `to_dict()` of each item in members (list)
96+
_items = []
97+
if self.members:
98+
for _item in self.members:
99+
if _item:
100+
_items.append(_item.to_dict())
101+
_dict["members"] = _items
102+
return _dict
103+
104+
@classmethod
105+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
106+
"""Create an instance of CreateFolderPayload from a dict"""
107+
if obj is None:
108+
return None
109+
110+
if not isinstance(obj, dict):
111+
return cls.model_validate(obj)
112+
113+
_obj = cls.model_validate(
114+
{
115+
"containerParentId": obj.get("containerParentId"),
116+
"labels": obj.get("labels"),
117+
"members": (
118+
[Member.from_dict(_item) for _item in obj["members"]] if obj.get("members") is not None else None
119+
),
120+
"name": obj.get("name"),
121+
}
122+
)
123+
return _obj
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# coding: utf-8
2+
3+
"""
4+
Resource Manager API
5+
6+
API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists
7+
8+
The version of the OpenAPI document: 2.0
9+
Generated by OpenAPI Generator (https://openapi-generator.tech)
10+
11+
Do not edit the class manually.
12+
""" # noqa: E501 docstring might be too long
13+
14+
from __future__ import annotations
15+
16+
import json
17+
import pprint
18+
from datetime import datetime
19+
from typing import Any, ClassVar, Dict, List, Optional, Set
20+
21+
from pydantic import BaseModel, ConfigDict, Field, StrictStr
22+
from typing_extensions import Self
23+
24+
from stackit.resourcemanager.models.parent import Parent
25+
26+
27+
class FolderResponse(BaseModel):
28+
"""
29+
FolderResponse
30+
"""
31+
32+
container_id: StrictStr = Field(description="Globally unique, user-friendly identifier.", alias="containerId")
33+
creation_time: datetime = Field(description="Timestamp at which the folder was created.", alias="creationTime")
34+
folder_id: StrictStr = Field(description="Globally unique folder identifier.", alias="folderId")
35+
labels: Optional[Dict[str, StrictStr]] = Field(
36+
default=None,
37+
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}`.",
38+
)
39+
name: StrictStr = Field(description="Folder name.")
40+
parent: Parent
41+
update_time: datetime = Field(description="Timestamp at which the folder was last modified.", alias="updateTime")
42+
__properties: ClassVar[List[str]] = [
43+
"containerId",
44+
"creationTime",
45+
"folderId",
46+
"labels",
47+
"name",
48+
"parent",
49+
"updateTime",
50+
]
51+
52+
model_config = ConfigDict(
53+
populate_by_name=True,
54+
validate_assignment=True,
55+
protected_namespaces=(),
56+
)
57+
58+
def to_str(self) -> str:
59+
"""Returns the string representation of the model using alias"""
60+
return pprint.pformat(self.model_dump(by_alias=True))
61+
62+
def to_json(self) -> str:
63+
"""Returns the JSON representation of the model using alias"""
64+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
65+
return json.dumps(self.to_dict())
66+
67+
@classmethod
68+
def from_json(cls, json_str: str) -> Optional[Self]:
69+
"""Create an instance of FolderResponse from a JSON string"""
70+
return cls.from_dict(json.loads(json_str))
71+
72+
def to_dict(self) -> Dict[str, Any]:
73+
"""Return the dictionary representation of the model using alias.
74+
75+
This has the following differences from calling pydantic's
76+
`self.model_dump(by_alias=True)`:
77+
78+
* `None` is only added to the output dict for nullable fields that
79+
were set at model initialization. Other fields with value `None`
80+
are ignored.
81+
"""
82+
excluded_fields: Set[str] = set([])
83+
84+
_dict = self.model_dump(
85+
by_alias=True,
86+
exclude=excluded_fields,
87+
exclude_none=True,
88+
)
89+
# override the default output from pydantic by calling `to_dict()` of parent
90+
if self.parent:
91+
_dict["parent"] = self.parent.to_dict()
92+
return _dict
93+
94+
@classmethod
95+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
96+
"""Create an instance of FolderResponse from a dict"""
97+
if obj is None:
98+
return None
99+
100+
if not isinstance(obj, dict):
101+
return cls.model_validate(obj)
102+
103+
_obj = cls.model_validate(
104+
{
105+
"containerId": obj.get("containerId"),
106+
"creationTime": obj.get("creationTime"),
107+
"folderId": obj.get("folderId"),
108+
"labels": obj.get("labels"),
109+
"name": obj.get("name"),
110+
"parent": Parent.from_dict(obj["parent"]) if obj.get("parent") is not None else None,
111+
"updateTime": obj.get("updateTime"),
112+
}
113+
)
114+
return _obj

0 commit comments

Comments
 (0)