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
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ updates:
`await client.close()` or an async context manager. Interactive
websocket streams use the generated `_without_preload_content`
operations.
- `CoreV1Api.delete_namespace` now returns a decoded dictionary rather
than `V1Status`, since a successful deletion can return either a
terminating Namespace or a Status.
- Individual resource-deletion methods that previously returned
`V1Status`, including `CoreV1Api.delete_namespace` and
`BatchV1Api.delete_namespaced_job`, now return decoded dictionaries in
both clients. A successful deletion can return either the deleted
resource or a Status; access response fields with dictionary keys
instead of model attributes.

See [kubernetes-client/python#2631][python-pr] and
[kubernetes-client/gen#305][gen-pr].
Expand Down
2 changes: 1 addition & 1 deletion examples/job_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def delete_job(api_instance):
body=client.V1DeleteOptions(
propagation_policy='Foreground',
grace_period_seconds=5))
print(f"Job deleted. status='{str(api_response.status)}'")
print(f"Job deleted. status='{str(api_response.get('status'))}'")


def main():
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/.openapi-generator/swagger.json-default.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c3d1f3292b01c5e3297240c5d49a69cd078653cd4a9f3d3482afa516a2d4c429
fdf8e53487f406c1ebc282797e8c33f290c6ad9bf8df9cd13a776dd6f82eaadd
11 changes: 10 additions & 1 deletion kubernetes/aio/e2e_test/test_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,13 @@ async def test_job_apis(self):
self.assertEqual(name, resp.metadata.name)

resp = await api.delete_namespaced_job(
name=name, body={}, namespace='default')
name=name, body={'propagationPolicy': 'Background'},
namespace='default')
self.assertIsInstance(resp, dict)
self.assertIn(resp['kind'], ('Job', 'Status'))
if resp['kind'] == 'Job':
self.assertEqual(name, resp['metadata']['name'])
else:
self.assertEqual('Success', resp['status'])
if 'details' in resp:
self.assertEqual(name, resp['details']['name'])
78 changes: 51 additions & 27 deletions kubernetes/aio/test/test_generated_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ async def asyncSetUp(self):
'metadata': {'resourceVersion': '1'},
'items': [],
}
self.response_status = 200
app = web.Application()
app.router.add_route('*', '/{path:.*}', self._handle_request)
self.runner = web.AppRunner(app)
Expand Down Expand Up @@ -90,7 +91,7 @@ async def _handle_request(self, request):
}).encode() + b'\n')
await response.write_eof()
return response
return web.json_response(self.response)
return web.json_response(self.response, status=self.response_status)

async def test_bearer_alias_supports_synchronous_token_refresh(self):
self.configuration.api_key['authorization'] = 'expired-token'
Expand Down Expand Up @@ -124,34 +125,57 @@ async def refresh(configuration):

async def test_delete_job_accepts_job_and_status_responses(self):
responses = (
{
'apiVersion': 'batch/v1',
'kind': 'Job',
'metadata': {'name': 'sample'},
'status': {'ready': 0},
},
{
'apiVersion': 'v1',
'kind': 'Status',
'status': 'Success',
'details': {'name': 'sample', 'kind': 'jobs'},
},
(
{
'apiVersion': 'batch/v1',
'kind': 'Job',
'metadata': {'name': 'sample'},
'status': {'ready': 0},
},
'Job',
{'ready': 0},
),
(
{
'apiVersion': 'v1',
'kind': 'Status',
'status': 'Success',
'details': {'name': 'sample', 'kind': 'jobs'},
},
'Status',
'Success',
),
)

for response in responses:
with self.subTest(kind=response['kind']):
self.response = response
deleted = await BatchV1Api(
self.api_client,
).delete_namespaced_job(
name='sample', namespace='default', body={},
)

self.assertEqual(response, deleted)
self.assertEqual(
'/apis/batch/v1/namespaces/default/jobs/sample',
self.requests[-1][0].path,
)
for response_status in (200, 202):
for response, expected_kind, expected_status in responses:
with self.subTest(
status=response_status, kind=expected_kind
):
self.response_status = response_status
self.response = response
deleted = await BatchV1Api(
self.api_client,
).delete_namespaced_job(
name='sample', namespace='default', body={},
)

self.assertIsInstance(deleted, dict)
self.assertIsNot(response, deleted)
self.assertEqual(response, deleted)
self.assertEqual(expected_kind, deleted['kind'])
self.assertEqual(expected_status, deleted['status'])
if expected_kind == 'Job':
self.assertIsInstance(deleted['status'], dict)
self.assertIsNot(response['status'], deleted['status'])
else:
self.assertIsInstance(deleted['status'], str)
request, body = self.requests[-1]
self.assertEqual({}, json.loads(body))
self.assertEqual(
'/apis/batch/v1/namespaces/default/jobs/sample',
request.path,
)

async def test_object_patches_use_strategic_merge(self):
self.response = {
Expand Down
72 changes: 36 additions & 36 deletions kubernetes/client/api/admissionregistration_v1_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4304,7 +4304,7 @@ def delete_mutating_admission_policy(
_content_type: Optional[StrictStr] = None,
_headers: Optional[Dict[StrictStr, Any]] = None,
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
) -> V1Status:
) -> object:
"""delete_mutating_admission_policy

delete a MutatingAdmissionPolicy
Expand Down Expand Up @@ -4372,8 +4372,8 @@ def delete_mutating_admission_policy(
)

_response_types_map: Dict[str, Optional[str]] = {
'200': "V1Status",
'202': "V1Status",
'200': "object",
'202': "object",
'401': None,
}
return self.api_client._call_with_legacy_options(
Expand Down Expand Up @@ -4412,7 +4412,7 @@ def delete_mutating_admission_policy_with_http_info(
_content_type: Optional[StrictStr] = None,
_headers: Optional[Dict[StrictStr, Any]] = None,
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
) -> Tuple[V1Status, int, Any]:
) -> Tuple[object, int, Any]:
"""delete_mutating_admission_policy

delete a MutatingAdmissionPolicy
Expand Down Expand Up @@ -4480,8 +4480,8 @@ def delete_mutating_admission_policy_with_http_info(
)

_response_types_map: Dict[str, Optional[str]] = {
'200': "V1Status",
'202': "V1Status",
'200': "object",
'202': "object",
'401': None,
}
return self.api_client._call_with_legacy_options(
Expand Down Expand Up @@ -4620,7 +4620,7 @@ def delete_mutating_admission_policy_binding(
_content_type: Optional[StrictStr] = None,
_headers: Optional[Dict[StrictStr, Any]] = None,
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
) -> V1Status:
) -> object:
"""delete_mutating_admission_policy_binding

delete a MutatingAdmissionPolicyBinding
Expand Down Expand Up @@ -4688,8 +4688,8 @@ def delete_mutating_admission_policy_binding(
)

_response_types_map: Dict[str, Optional[str]] = {
'200': "V1Status",
'202': "V1Status",
'200': "object",
'202': "object",
'401': None,
}
return self.api_client._call_with_legacy_options(
Expand Down Expand Up @@ -4728,7 +4728,7 @@ def delete_mutating_admission_policy_binding_with_http_info(
_content_type: Optional[StrictStr] = None,
_headers: Optional[Dict[StrictStr, Any]] = None,
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
) -> Tuple[V1Status, int, Any]:
) -> Tuple[object, int, Any]:
"""delete_mutating_admission_policy_binding

delete a MutatingAdmissionPolicyBinding
Expand Down Expand Up @@ -4796,8 +4796,8 @@ def delete_mutating_admission_policy_binding_with_http_info(
)

_response_types_map: Dict[str, Optional[str]] = {
'200': "V1Status",
'202': "V1Status",
'200': "object",
'202': "object",
'401': None,
}
return self.api_client._call_with_legacy_options(
Expand Down Expand Up @@ -4936,7 +4936,7 @@ def delete_mutating_webhook_configuration(
_content_type: Optional[StrictStr] = None,
_headers: Optional[Dict[StrictStr, Any]] = None,
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
) -> V1Status:
) -> object:
"""delete_mutating_webhook_configuration

delete a MutatingWebhookConfiguration
Expand Down Expand Up @@ -5004,8 +5004,8 @@ def delete_mutating_webhook_configuration(
)

_response_types_map: Dict[str, Optional[str]] = {
'200': "V1Status",
'202': "V1Status",
'200': "object",
'202': "object",
'401': None,
}
return self.api_client._call_with_legacy_options(
Expand Down Expand Up @@ -5044,7 +5044,7 @@ def delete_mutating_webhook_configuration_with_http_info(
_content_type: Optional[StrictStr] = None,
_headers: Optional[Dict[StrictStr, Any]] = None,
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
) -> Tuple[V1Status, int, Any]:
) -> Tuple[object, int, Any]:
"""delete_mutating_webhook_configuration

delete a MutatingWebhookConfiguration
Expand Down Expand Up @@ -5112,8 +5112,8 @@ def delete_mutating_webhook_configuration_with_http_info(
)

_response_types_map: Dict[str, Optional[str]] = {
'200': "V1Status",
'202': "V1Status",
'200': "object",
'202': "object",
'401': None,
}
return self.api_client._call_with_legacy_options(
Expand Down Expand Up @@ -5252,7 +5252,7 @@ def delete_validating_admission_policy(
_content_type: Optional[StrictStr] = None,
_headers: Optional[Dict[StrictStr, Any]] = None,
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
) -> V1Status:
) -> object:
"""delete_validating_admission_policy

delete a ValidatingAdmissionPolicy
Expand Down Expand Up @@ -5320,8 +5320,8 @@ def delete_validating_admission_policy(
)

_response_types_map: Dict[str, Optional[str]] = {
'200': "V1Status",
'202': "V1Status",
'200': "object",
'202': "object",
'401': None,
}
return self.api_client._call_with_legacy_options(
Expand Down Expand Up @@ -5360,7 +5360,7 @@ def delete_validating_admission_policy_with_http_info(
_content_type: Optional[StrictStr] = None,
_headers: Optional[Dict[StrictStr, Any]] = None,
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
) -> Tuple[V1Status, int, Any]:
) -> Tuple[object, int, Any]:
"""delete_validating_admission_policy

delete a ValidatingAdmissionPolicy
Expand Down Expand Up @@ -5428,8 +5428,8 @@ def delete_validating_admission_policy_with_http_info(
)

_response_types_map: Dict[str, Optional[str]] = {
'200': "V1Status",
'202': "V1Status",
'200': "object",
'202': "object",
'401': None,
}
return self.api_client._call_with_legacy_options(
Expand Down Expand Up @@ -5568,7 +5568,7 @@ def delete_validating_admission_policy_binding(
_content_type: Optional[StrictStr] = None,
_headers: Optional[Dict[StrictStr, Any]] = None,
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
) -> V1Status:
) -> object:
"""delete_validating_admission_policy_binding

delete a ValidatingAdmissionPolicyBinding
Expand Down Expand Up @@ -5636,8 +5636,8 @@ def delete_validating_admission_policy_binding(
)

_response_types_map: Dict[str, Optional[str]] = {
'200': "V1Status",
'202': "V1Status",
'200': "object",
'202': "object",
'401': None,
}
return self.api_client._call_with_legacy_options(
Expand Down Expand Up @@ -5676,7 +5676,7 @@ def delete_validating_admission_policy_binding_with_http_info(
_content_type: Optional[StrictStr] = None,
_headers: Optional[Dict[StrictStr, Any]] = None,
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
) -> Tuple[V1Status, int, Any]:
) -> Tuple[object, int, Any]:
"""delete_validating_admission_policy_binding

delete a ValidatingAdmissionPolicyBinding
Expand Down Expand Up @@ -5744,8 +5744,8 @@ def delete_validating_admission_policy_binding_with_http_info(
)

_response_types_map: Dict[str, Optional[str]] = {
'200': "V1Status",
'202': "V1Status",
'200': "object",
'202': "object",
'401': None,
}
return self.api_client._call_with_legacy_options(
Expand Down Expand Up @@ -5884,7 +5884,7 @@ def delete_validating_webhook_configuration(
_content_type: Optional[StrictStr] = None,
_headers: Optional[Dict[StrictStr, Any]] = None,
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
) -> V1Status:
) -> object:
"""delete_validating_webhook_configuration

delete a ValidatingWebhookConfiguration
Expand Down Expand Up @@ -5952,8 +5952,8 @@ def delete_validating_webhook_configuration(
)

_response_types_map: Dict[str, Optional[str]] = {
'200': "V1Status",
'202': "V1Status",
'200': "object",
'202': "object",
'401': None,
}
return self.api_client._call_with_legacy_options(
Expand Down Expand Up @@ -5992,7 +5992,7 @@ def delete_validating_webhook_configuration_with_http_info(
_content_type: Optional[StrictStr] = None,
_headers: Optional[Dict[StrictStr, Any]] = None,
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
) -> Tuple[V1Status, int, Any]:
) -> Tuple[object, int, Any]:
"""delete_validating_webhook_configuration

delete a ValidatingWebhookConfiguration
Expand Down Expand Up @@ -6060,8 +6060,8 @@ def delete_validating_webhook_configuration_with_http_info(
)

_response_types_map: Dict[str, Optional[str]] = {
'200': "V1Status",
'202': "V1Status",
'200': "object",
'202': "object",
'401': None,
}
return self.api_client._call_with_legacy_options(
Expand Down
Loading