Skip to content
Merged
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ make package
Then install the built wheel:

```bash
pip install dist/osc_sdk_python-0.41.0-py3-none-any.whl
pip install dist/osc_sdk_python-0.42.0-py3-none-any.whl
```

---
Expand Down
2 changes: 1 addition & 1 deletion osc_sdk_python/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.41.0
0.42.0
8 changes: 8 additions & 0 deletions osc_sdk_python/codegen/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ def class_name(value: str) -> str:


def schema_type(schema: dict[str, Any], ref_resolver=class_name) -> str:
if schema.get("type") == "null":
return "None"

if schema.get("nullable"):
return (
schema_type(
Expand All @@ -55,6 +58,11 @@ def schema_type(schema: dict[str, Any], ref_resolver=class_name) -> str:
if composed in {"oneOf", "anyOf"}:
option_types = [schema_type(option, ref_resolver) for option in options]
if "Any" not in option_types:
option_types = [
option_type for option_type in option_types if option_type != "None"
] + [
option_type for option_type in option_types if option_type == "None"
]
if composed == "oneOf":
logger.warning(
"OpenAPI oneOf with %d schemas represented as a union; "
Expand Down
24 changes: 19 additions & 5 deletions osc_sdk_python/codegen/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,25 @@ def _field_dump(field: Field) -> str:

def _model_imports(operations: list[Operation]) -> list[str]:
names = {operation.request_model.name for operation in operations}
names.update(
operation.response_model
for operation in operations
if re.fullmatch(r"[A-Za-z_][A-Za-z0-9_]*", operation.response_model)
)
builtins = {
"Any",
"None",
"Literal",
"list",
"dict",
"str",
"int",
"float",
"bool",
}
for operation in operations:
names.update(
name
for name in re.findall(
r"\b[A-Za-z_][A-Za-z0-9_]*\b", operation.response_model
)
if name not in builtins
)
return sorted(names)


Expand Down
32 changes: 32 additions & 0 deletions osc_sdk_python/generated/oks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@

from .async_client import AsyncOksTypedMixin
from .models import (
AccessKey,
AdmissionFlags,
AdmissionFlagsInput,
AdmissionPlugins,
AdmissionPluginsResponse,
AuthStrategy,
AutoMaintenances,
AutoUpgradeMaintenance,
Expand All @@ -20,18 +23,30 @@
ClusterUpdate,
ControlPlanesResponse,
CreateClusterRequest,
CreateEimUserRequest,
CreateProjectRequest,
Cursor,
DeleteClusterRequest,
DeleteEimUserRequest,
DeleteProjectRequest,
DetailResponse,
DetailsResponse,
EimUser,
EimUserResponse,
EimUserType,
EimUserTypesResponse,
EimUsersResponse,
EnryptedResponse,
ErrorItem,
ErrorResponse,
GetAdmissionPluginsRequest,
GetCPSubregionsRequest,
GetClientIPRequest,
GetClusterRequest,
GetClusterTemplateRequest,
GetControlPlanePlansRequest,
GetEimUserTypesRequest,
GetEimUsersRequest,
GetKubeconfigRequest,
GetKubeconfigWithPubkeyNACLRequest,
GetKubernetesVersionsRequest,
Expand All @@ -58,6 +73,7 @@
Net,
NetPeeringAcceptance,
NetPeeringRequest,
NetSpecific,
NetsResponse,
Nodepool,
OKSQuotas,
Expand Down Expand Up @@ -109,8 +125,11 @@

__all__ = [
"AsyncOksTypedMixin",
'AccessKey',
'AdmissionFlags',
'AdmissionFlagsInput',
'AdmissionPlugins',
'AdmissionPluginsResponse',
'AuthStrategy',
'AutoMaintenances',
'AutoUpgradeMaintenance',
Expand All @@ -123,18 +142,30 @@
'ClusterUpdate',
'ControlPlanesResponse',
'CreateClusterRequest',
'CreateEimUserRequest',
'CreateProjectRequest',
'Cursor',
'DeleteClusterRequest',
'DeleteEimUserRequest',
'DeleteProjectRequest',
'DetailResponse',
'DetailsResponse',
'EimUser',
'EimUserResponse',
'EimUserType',
'EimUserTypesResponse',
'EimUsersResponse',
'EnryptedResponse',
'ErrorItem',
'ErrorResponse',
'GetAdmissionPluginsRequest',
'GetCPSubregionsRequest',
'GetClientIPRequest',
'GetClusterRequest',
'GetClusterTemplateRequest',
'GetControlPlanePlansRequest',
'GetEimUserTypesRequest',
'GetEimUsersRequest',
'GetKubeconfigRequest',
'GetKubeconfigWithPubkeyNACLRequest',
'GetKubernetesVersionsRequest',
Expand All @@ -161,6 +192,7 @@
'Net',
'NetPeeringAcceptance',
'NetPeeringRequest',
'NetSpecific',
'NetsResponse',
'Nodepool',
'OKSQuotas',
Expand Down
149 changes: 149 additions & 0 deletions osc_sdk_python/generated/oks/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,31 @@
from osc_sdk_python.exceptions import SdkResponseError, SdkValidationError
from osc_sdk_python.runtime.request import RequestSpec
from .models import (
AdmissionPluginsResponse,
CPSubregionsResponse,
ClusterResponse,
ClusterResponseList,
ControlPlanesResponse,
CreateClusterRequest,
CreateEimUserRequest,
CreateProjectRequest,
DeleteClusterRequest,
DeleteEimUserRequest,
DeleteProjectRequest,
DetailResponse,
DetailsResponse,
EimUserResponse,
EimUserTypesResponse,
EimUsersResponse,
EnryptedResponse,
GetAdmissionPluginsRequest,
GetCPSubregionsRequest,
GetClientIPRequest,
GetClusterRequest,
GetClusterTemplateRequest,
GetControlPlanePlansRequest,
GetEimUserTypesRequest,
GetEimUsersRequest,
GetKubeconfigRequest,
GetKubeconfigWithPubkeyNACLRequest,
GetKubernetesVersionsRequest,
Expand Down Expand Up @@ -340,6 +351,117 @@ async def get_project_nets(
)
return _validate_response(NetsResponse, response)

async def get_eim_users(
self,
request: GetEimUsersRequest | None = None,
) -> EimUsersResponse:
request = _validate_request(GetEimUsersRequest, request)

path_params = {
'project_id': request.project_id,
}
query_params = {
}
response = await self.call.request(
RequestSpec(
service="oks",
method="GET",
path="/projects/{project_id}/eim_users",
json_body=None,
query_params={
key: value
for key, value in query_params.items()
if value is not None
},
),
path_params=path_params,
)
return _validate_response(EimUsersResponse, response)

async def create_eim_user(
self,
request: CreateEimUserRequest | None = None,
) -> EimUserResponse | EnryptedResponse:
request = _validate_request(CreateEimUserRequest, request)

path_params = {
'project_id': request.project_id,
}
query_params = {
'user': request.user,
'ttl': request.ttl,
}
response = await self.call.request(
RequestSpec(
service="oks",
method="POST",
path="/projects/{project_id}/eim_users",
json_body=None,
query_params={
key: value
for key, value in query_params.items()
if value is not None
},
),
path_params=path_params,
)
return _validate_response(EimUserResponse | EnryptedResponse, response)

async def get_eim_user_types(
self,
request: GetEimUserTypesRequest | None = None,
) -> EimUserTypesResponse:
request = _validate_request(GetEimUserTypesRequest, request)

path_params = {
'project_id': request.project_id,
}
query_params = {
}
response = await self.call.request(
RequestSpec(
service="oks",
method="GET",
path="/projects/{project_id}/eim_users/types",
json_body=None,
query_params={
key: value
for key, value in query_params.items()
if value is not None
},
),
path_params=path_params,
)
return _validate_response(EimUserTypesResponse, response)

async def delete_eim_user(
self,
request: DeleteEimUserRequest | None = None,
) -> DetailsResponse:
request = _validate_request(DeleteEimUserRequest, request)

path_params = {
'project_id': request.project_id,
'user': request.user,
}
query_params = {
}
response = await self.call.request(
RequestSpec(
service="oks",
method="DELETE",
path="/projects/{project_id}/eim_users/{user}",
json_body=None,
query_params={
key: value
for key, value in query_params.items()
if value is not None
},
),
path_params=path_params,
)
return _validate_response(DetailsResponse, response)

async def list_clusters_by_project_id(
self,
request: ListClustersByProjectIDRequest | None = None,
Expand Down Expand Up @@ -679,6 +801,33 @@ async def get_control_plane_plans(
)
return _validate_response(ControlPlanesResponse, response)

async def get_admission_plugins(
self,
request: GetAdmissionPluginsRequest | None = None,
) -> AdmissionPluginsResponse:
request = _validate_request(GetAdmissionPluginsRequest, request)

path_params = {
}
query_params = {
'version': request.version,
}
response = await self.call.request(
RequestSpec(
service="oks",
method="GET",
path="/clusters/limits/admission_plugins",
json_body=None,
query_params={
key: value
for key, value in query_params.items()
if value is not None
},
),
path_params=path_params,
)
return _validate_response(AdmissionPluginsResponse, response)

async def get_project_template(
self,
request: GetProjectTemplateRequest | None = None,
Expand Down
Loading