diff --git a/docs/reference/exceptions.md b/docs/reference/exceptions.md index 3fb38a2..c1faca1 100644 --- a/docs/reference/exceptions.md +++ b/docs/reference/exceptions.md @@ -1,5 +1,18 @@ # Exceptions +The high-level client raises SDK exceptions for HTTP error responses rather +than returning error models as operation results: + +- HTTP 422 raises `OblidogValidationError`. +- Typed integration run conflicts raise `OblidogConflictError`; its `code` + contains the integration conflict reason. +- Other HTTP errors raise `OblidogApiError`. + +These exceptions preserve the original HTTP status in `status_code` and the +complete response bytes in `content`, including error codes and `params`. +Undocumented statuses also raise `OblidogApiError` with the generated exception +retained as the cause. + ::: oblidog_client.OblidogError ::: oblidog_client.OblidogApiError diff --git a/openapi/integration.json b/openapi/integration.json index c273712..8d07b14 100644 --- a/openapi/integration.json +++ b/openapi/integration.json @@ -1,6 +1,116 @@ { "components": { "schemas": { + "ApiErrorResponse": { + "properties": { + "code": { + "enum": [ + "auth_invalid_credentials", + "user_inactive", + "auth_invalid_token", + "auth_required", + "auth_session_expired", + "auth_invalid_api_key", + "auth_inactive_api_key", + "auth_csrf_invalid", + "auth_origin_forbidden", + "permission_denied", + "capability_disabled", + "demo_read_only", + "demo_limit_reached", + "demo_request_too_large", + "demo_reset_running", + "demo_reset_failed", + "resource_not_found", + "user_not_found", + "user_email_conflict", + "user_incorrect_password", + "user_same_password", + "user_self_delete_forbidden", + "ledger_not_found", + "ledger_member_not_found", + "ledger_membership_conflict", + "ledger_owner_change_forbidden", + "ledger_owner_remove_forbidden", + "ledger_categories_in_use", + "ledger_invalid_values", + "category_not_found", + "category_conflict", + "category_code_conflict", + "category_code_invalid", + "category_group_not_found", + "category_group_conflict", + "category_group_in_use", + "category_group_archived", + "category_invalid_values", + "category_group_invalid_values", + "category_cross_ledger", + "category_schema_not_found", + "category_schema_not_configured", + "category_schema_invalid", + "category_schema_incompatible", + "category_data_invalid", + "category_data_not_found", + "category_csv_unsupported", + "counterparty_not_found", + "counterparty_conflict", + "counterparty_in_use", + "counterparty_invalid_values", + "counterparty_required", + "counterparty_preview_stale", + "obligation_not_found", + "obligation_conflict", + "obligation_manual_forbidden", + "obligation_invalid_key", + "obligation_invalid_period", + "obligation_invalid_lifecycle", + "obligation_read_only", + "obligation_invalid_values", + "obligation_not_ready", + "obligation_component_not_found", + "obligation_component_conflict", + "integration_not_found", + "integration_key_not_found", + "integration_conflict", + "integration_invalid_limits", + "invitation_conflict", + "invitation_accepted", + "invitation_revoked", + "invitation_expired", + "invitation_not_found", + "system_run_running", + "system_run_not_found", + "system_run_unknown_tasks", + "system_run_disabled_tasks", + "system_run_non_manual_tasks", + "legacy_import_running", + "legacy_import_disabled", + "legacy_import_not_found", + "analytics_invalid_range", + "service_unavailable", + "request_invalid", + "request_validation_failed", + "internal_error" + ], + "title": "Code", + "type": "string" + }, + "detail": { + "title": "Detail" + }, + "params": { + "additionalProperties": true, + "title": "Params", + "type": "object" + } + }, + "required": [ + "detail", + "code" + ], + "title": "ApiErrorResponse", + "type": "object" + }, "CategoryDataRecordPublic": { "properties": { "created_at": { @@ -173,19 +283,6 @@ "title": "EffectiveValueSourceMode", "type": "string" }, - "HTTPValidationError": { - "properties": { - "detail": { - "items": { - "$ref": "#/components/schemas/ValidationError" - }, - "title": "Detail", - "type": "array" - } - }, - "title": "HTTPValidationError", - "type": "object" - }, "IntegrationCategoryDataRecordCreate": { "additionalProperties": false, "description": "A category observation submitted by its authenticated integration.", @@ -245,12 +342,110 @@ }, "IntegrationConflictResponse": { "properties": { + "code": { + "enum": [ + "auth_invalid_credentials", + "user_inactive", + "auth_invalid_token", + "auth_required", + "auth_session_expired", + "auth_invalid_api_key", + "auth_inactive_api_key", + "auth_csrf_invalid", + "auth_origin_forbidden", + "permission_denied", + "capability_disabled", + "demo_read_only", + "demo_limit_reached", + "demo_request_too_large", + "demo_reset_running", + "demo_reset_failed", + "resource_not_found", + "user_not_found", + "user_email_conflict", + "user_incorrect_password", + "user_same_password", + "user_self_delete_forbidden", + "ledger_not_found", + "ledger_member_not_found", + "ledger_membership_conflict", + "ledger_owner_change_forbidden", + "ledger_owner_remove_forbidden", + "ledger_categories_in_use", + "ledger_invalid_values", + "category_not_found", + "category_conflict", + "category_code_conflict", + "category_code_invalid", + "category_group_not_found", + "category_group_conflict", + "category_group_in_use", + "category_group_archived", + "category_invalid_values", + "category_group_invalid_values", + "category_cross_ledger", + "category_schema_not_found", + "category_schema_not_configured", + "category_schema_invalid", + "category_schema_incompatible", + "category_data_invalid", + "category_data_not_found", + "category_csv_unsupported", + "counterparty_not_found", + "counterparty_conflict", + "counterparty_in_use", + "counterparty_invalid_values", + "counterparty_required", + "counterparty_preview_stale", + "obligation_not_found", + "obligation_conflict", + "obligation_manual_forbidden", + "obligation_invalid_key", + "obligation_invalid_period", + "obligation_invalid_lifecycle", + "obligation_read_only", + "obligation_invalid_values", + "obligation_not_ready", + "obligation_component_not_found", + "obligation_component_conflict", + "integration_not_found", + "integration_key_not_found", + "integration_conflict", + "integration_invalid_limits", + "invitation_conflict", + "invitation_accepted", + "invitation_revoked", + "invitation_expired", + "invitation_not_found", + "system_run_running", + "system_run_not_found", + "system_run_unknown_tasks", + "system_run_disabled_tasks", + "system_run_non_manual_tasks", + "legacy_import_running", + "legacy_import_disabled", + "legacy_import_not_found", + "analytics_invalid_range", + "service_unavailable", + "request_invalid", + "request_validation_failed", + "internal_error" + ], + "title": "Code", + "type": "string" + }, "detail": { "$ref": "#/components/schemas/IntegrationConflictDetail" + }, + "params": { + "additionalProperties": true, + "title": "Params", + "type": "object" } }, "required": [ - "detail" + "detail", + "code" ], "title": "IntegrationConflictResponse", "type": "object" @@ -1230,46 +1425,6 @@ "title": "ObligationsPublic", "type": "object" }, - "ValidationError": { - "properties": { - "ctx": { - "title": "Context", - "type": "object" - }, - "input": { - "title": "Input" - }, - "loc": { - "items": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "integer" - } - ] - }, - "title": "Location", - "type": "array" - }, - "msg": { - "title": "Message", - "type": "string" - }, - "type": { - "title": "Error Type", - "type": "string" - } - }, - "required": [ - "loc", - "msg", - "type" - ], - "title": "ValidationError", - "type": "object" - }, "ValueState": { "enum": [ "unknown", @@ -1369,15 +1524,95 @@ }, "description": "Successful Response" }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Bad Request" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Unauthorized" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Forbidden" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Not Found" + }, + "409": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Conflict" + }, + "413": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Content Too Large" + }, "422": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/HTTPValidationError" + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Unprocessable Content" + }, + "500": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Internal Server Error" + }, + "503": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" } } }, - "description": "Validation Error" + "description": "Service Unavailable" } }, "security": [ @@ -1413,15 +1648,95 @@ }, "description": "Successful Response" }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Bad Request" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Unauthorized" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Forbidden" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Not Found" + }, + "409": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Conflict" + }, + "413": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Content Too Large" + }, "422": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/HTTPValidationError" + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Unprocessable Content" + }, + "500": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" } } }, - "description": "Validation Error" + "description": "Internal Server Error" + }, + "503": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Service Unavailable" } }, "security": [ @@ -1448,6 +1763,96 @@ } }, "description": "Successful Response" + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Bad Request" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Unauthorized" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Forbidden" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Not Found" + }, + "409": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Conflict" + }, + "413": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Content Too Large" + }, + "422": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Unprocessable Content" + }, + "500": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Internal Server Error" + }, + "503": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Service Unavailable" } }, "security": [ @@ -1474,22 +1879,112 @@ } }, "description": "Successful Response" - } - }, - "security": [ - { - "IntegrationApiKey": [] - } - ], - "summary": "Read Integration Category Data Schema", - "tags": [ - "integration" - ] - } - }, - "/api/v1/integration/context": { - "get": { - "operationId": "integration-read_integration_context", + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Bad Request" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Unauthorized" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Forbidden" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Not Found" + }, + "409": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Conflict" + }, + "413": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Content Too Large" + }, + "422": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Unprocessable Content" + }, + "500": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Internal Server Error" + }, + "503": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Service Unavailable" + } + }, + "security": [ + { + "IntegrationApiKey": [] + } + ], + "summary": "Read Integration Category Data Schema", + "tags": [ + "integration" + ] + } + }, + "/api/v1/integration/context": { + "get": { + "operationId": "integration-read_integration_context", "responses": { "200": { "content": { @@ -1500,6 +1995,96 @@ } }, "description": "Successful Response" + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Bad Request" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Unauthorized" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Forbidden" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Not Found" + }, + "409": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Conflict" + }, + "413": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Content Too Large" + }, + "422": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Unprocessable Content" + }, + "500": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Internal Server Error" + }, + "503": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Service Unavailable" } }, "security": [ @@ -1581,15 +2166,95 @@ }, "description": "Successful Response" }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Bad Request" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Unauthorized" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Forbidden" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Not Found" + }, + "409": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Conflict" + }, + "413": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Content Too Large" + }, "422": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/HTTPValidationError" + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Unprocessable Content" + }, + "500": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Internal Server Error" + }, + "503": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" } } }, - "description": "Validation Error" + "description": "Service Unavailable" } }, "security": [ @@ -1633,25 +2298,105 @@ }, "description": "Successful Response" }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Bad Request" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Unauthorized" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Forbidden" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Not Found" + }, + "409": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Conflict" + }, + "413": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Content Too Large" + }, "422": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/HTTPValidationError" + "$ref": "#/components/schemas/ApiErrorResponse" } } }, - "description": "Validation Error" - } - }, - "security": [ - { - "IntegrationApiKey": [] - } - ], - "summary": "Read Integration Obligation", - "tags": [ - "integration" + "description": "Unprocessable Content" + }, + "500": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Internal Server Error" + }, + "503": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Service Unavailable" + } + }, + "security": [ + { + "IntegrationApiKey": [] + } + ], + "summary": "Read Integration Obligation", + "tags": [ + "integration" ] }, "patch": { @@ -1678,30 +2423,516 @@ "schema": { "$ref": "#/components/schemas/ObligationIntegrationUpdate" } - } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ObligationPublic" + } + } + }, + "description": "Successful Response" + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Bad Request" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Unauthorized" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Forbidden" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Not Found" + }, + "409": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Conflict" + }, + "413": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Content Too Large" + }, + "422": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Unprocessable Content" + }, + "500": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Internal Server Error" + }, + "503": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Service Unavailable" + } + }, + "security": [ + { + "IntegrationApiKey": [] + } + ], + "summary": "Update Integration Obligation", + "tags": [ + "integration" + ] + } + }, + "/api/v1/integration/obligations/{period}/cancel": { + "post": { + "operationId": "integration-cancel_integration_obligation", + "parameters": [ + { + "description": "Billing period in YYYY-MM format. Full obligation keys are temporarily accepted for client migration.", + "in": "path", + "name": "period", + "required": true, + "schema": { + "description": "Billing period in YYYY-MM format. Full obligation keys are temporarily accepted for client migration.", + "examples": [ + "2026-09" + ], + "title": "Period", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ObligationPublic" + } + } + }, + "description": "Successful Response" + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Bad Request" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Unauthorized" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Forbidden" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Not Found" + }, + "409": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Conflict" + }, + "413": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Content Too Large" + }, + "422": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Unprocessable Content" + }, + "500": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Internal Server Error" + }, + "503": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Service Unavailable" + } + }, + "security": [ + { + "IntegrationApiKey": [] + } + ], + "summary": "Cancel Integration Obligation", + "tags": [ + "integration" + ] + } + }, + "/api/v1/integration/obligations/{period}/components": { + "get": { + "operationId": "integration-read_integration_obligation_components", + "parameters": [ + { + "description": "Billing period in YYYY-MM format. Full obligation keys are temporarily accepted for client migration.", + "in": "path", + "name": "period", + "required": true, + "schema": { + "description": "Billing period in YYYY-MM format. Full obligation keys are temporarily accepted for client migration.", + "examples": [ + "2026-09" + ], + "title": "Period", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ObligationComponentsPublic" + } + } + }, + "description": "Successful Response" + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Bad Request" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Unauthorized" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Forbidden" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Not Found" + }, + "409": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Conflict" + }, + "413": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Content Too Large" + }, + "422": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Unprocessable Content" + }, + "500": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Internal Server Error" + }, + "503": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Service Unavailable" + } + }, + "security": [ + { + "IntegrationApiKey": [] + } + ], + "summary": "Read Integration Obligation Components", + "tags": [ + "integration" + ] + } + }, + "/api/v1/integration/obligations/{period}/components/upsert": { + "put": { + "operationId": "integration-upsert_integration_obligation_component", + "parameters": [ + { + "description": "Billing period in YYYY-MM format. Full obligation keys are temporarily accepted for client migration.", + "in": "path", + "name": "period", + "required": true, + "schema": { + "description": "Billing period in YYYY-MM format. Full obligation keys are temporarily accepted for client migration.", + "examples": [ + "2026-09" + ], + "title": "Period", + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IntegrationObligationComponentUpsert" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ObligationComponentUpsertResult" + } + } + }, + "description": "Successful Response" + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Bad Request" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Unauthorized" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Forbidden" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Not Found" + }, + "409": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Conflict" + }, + "413": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Content Too Large" + }, + "422": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Unprocessable Content" }, - "required": true - }, - "responses": { - "200": { + "500": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ObligationPublic" + "$ref": "#/components/schemas/ApiErrorResponse" } } }, - "description": "Successful Response" + "description": "Internal Server Error" }, - "422": { + "503": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/HTTPValidationError" + "$ref": "#/components/schemas/ApiErrorResponse" } } }, - "description": "Validation Error" + "description": "Service Unavailable" } }, "security": [ @@ -1709,15 +2940,15 @@ "IntegrationApiKey": [] } ], - "summary": "Update Integration Obligation", + "summary": "Upsert Integration Obligation Component", "tags": [ "integration" ] } }, - "/api/v1/integration/obligations/{period}/cancel": { + "/api/v1/integration/obligations/{period}/error": { "post": { - "operationId": "integration-cancel_integration_obligation", + "operationId": "integration-mark_integration_obligation_error", "parameters": [ { "description": "Billing period in YYYY-MM format. Full obligation keys are temporarily accepted for client migration.", @@ -1745,15 +2976,95 @@ }, "description": "Successful Response" }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Bad Request" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Unauthorized" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Forbidden" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Not Found" + }, + "409": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Conflict" + }, + "413": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Content Too Large" + }, "422": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/HTTPValidationError" + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Unprocessable Content" + }, + "500": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Internal Server Error" + }, + "503": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" } } }, - "description": "Validation Error" + "description": "Service Unavailable" } }, "security": [ @@ -1761,15 +3072,15 @@ "IntegrationApiKey": [] } ], - "summary": "Cancel Integration Obligation", + "summary": "Mark Integration Obligation Error", "tags": [ "integration" ] } }, - "/api/v1/integration/obligations/{period}/components": { - "get": { - "operationId": "integration-read_integration_obligation_components", + "/api/v1/integration/obligations/{period}/mark-paid": { + "post": { + "operationId": "integration-mark_integration_obligation_paid", "parameters": [ { "description": "Billing period in YYYY-MM format. Full obligation keys are temporarily accepted for client migration.", @@ -1791,21 +3102,101 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ObligationComponentsPublic" + "$ref": "#/components/schemas/ObligationPublic" } } }, "description": "Successful Response" }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Bad Request" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Unauthorized" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Forbidden" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Not Found" + }, + "409": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Conflict" + }, + "413": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Content Too Large" + }, "422": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/HTTPValidationError" + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Unprocessable Content" + }, + "500": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Internal Server Error" + }, + "503": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" } } }, - "description": "Validation Error" + "description": "Service Unavailable" } }, "security": [ @@ -1813,15 +3204,15 @@ "IntegrationApiKey": [] } ], - "summary": "Read Integration Obligation Components", + "summary": "Mark Integration Obligation Paid", "tags": [ "integration" ] } }, - "/api/v1/integration/obligations/{period}/components/upsert": { - "put": { - "operationId": "integration-upsert_integration_obligation_component", + "/api/v1/integration/obligations/{period}/notes": { + "post": { + "operationId": "integration-append_integration_obligation_note", "parameters": [ { "description": "Billing period in YYYY-MM format. Full obligation keys are temporarily accepted for client migration.", @@ -1842,7 +3233,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/IntegrationObligationComponentUpsert" + "$ref": "#/components/schemas/ObligationNoteAppend" } } }, @@ -1853,125 +3244,101 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ObligationComponentUpsertResult" + "$ref": "#/components/schemas/ObligationPublic" } } }, "description": "Successful Response" }, - "422": { + "400": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/HTTPValidationError" + "$ref": "#/components/schemas/ApiErrorResponse" } } }, - "description": "Validation Error" - } - }, - "security": [ - { - "IntegrationApiKey": [] - } - ], - "summary": "Upsert Integration Obligation Component", - "tags": [ - "integration" - ] - } - }, - "/api/v1/integration/obligations/{period}/error": { - "post": { - "operationId": "integration-mark_integration_obligation_error", - "parameters": [ - { - "description": "Billing period in YYYY-MM format. Full obligation keys are temporarily accepted for client migration.", - "in": "path", - "name": "period", - "required": true, - "schema": { - "description": "Billing period in YYYY-MM format. Full obligation keys are temporarily accepted for client migration.", - "examples": [ - "2026-09" - ], - "title": "Period", - "type": "string" - } - } - ], - "responses": { - "200": { + "description": "Bad Request" + }, + "401": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ObligationPublic" + "$ref": "#/components/schemas/ApiErrorResponse" } } }, - "description": "Successful Response" + "description": "Unauthorized" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Forbidden" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Not Found" + }, + "409": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Conflict" + }, + "413": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Content Too Large" }, "422": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/HTTPValidationError" + "$ref": "#/components/schemas/ApiErrorResponse" } } }, - "description": "Validation Error" - } - }, - "security": [ - { - "IntegrationApiKey": [] - } - ], - "summary": "Mark Integration Obligation Error", - "tags": [ - "integration" - ] - } - }, - "/api/v1/integration/obligations/{period}/mark-paid": { - "post": { - "operationId": "integration-mark_integration_obligation_paid", - "parameters": [ - { - "description": "Billing period in YYYY-MM format. Full obligation keys are temporarily accepted for client migration.", - "in": "path", - "name": "period", - "required": true, - "schema": { - "description": "Billing period in YYYY-MM format. Full obligation keys are temporarily accepted for client migration.", - "examples": [ - "2026-09" - ], - "title": "Period", - "type": "string" - } - } - ], - "responses": { - "200": { + "description": "Unprocessable Content" + }, + "500": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ObligationPublic" + "$ref": "#/components/schemas/ApiErrorResponse" } } }, - "description": "Successful Response" + "description": "Internal Server Error" }, - "422": { + "503": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/HTTPValidationError" + "$ref": "#/components/schemas/ApiErrorResponse" } } }, - "description": "Validation Error" + "description": "Service Unavailable" } }, "security": [ @@ -1979,15 +3346,15 @@ "IntegrationApiKey": [] } ], - "summary": "Mark Integration Obligation Paid", + "summary": "Append Integration Obligation Note", "tags": [ "integration" ] } }, - "/api/v1/integration/obligations/{period}/notes": { - "post": { - "operationId": "integration-append_integration_obligation_note", + "/api/v1/integration/obligations/{period}/ready": { + "patch": { + "operationId": "integration-mark_integration_obligation_ready", "parameters": [ { "description": "Billing period in YYYY-MM format. Full obligation keys are temporarily accepted for client migration.", @@ -2004,16 +3371,6 @@ } } ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ObligationNoteAppend" - } - } - }, - "required": true - }, "responses": { "200": { "content": { @@ -2025,67 +3382,95 @@ }, "description": "Successful Response" }, - "422": { + "400": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/HTTPValidationError" + "$ref": "#/components/schemas/ApiErrorResponse" } } }, - "description": "Validation Error" - } - }, - "security": [ - { - "IntegrationApiKey": [] - } - ], - "summary": "Append Integration Obligation Note", - "tags": [ - "integration" - ] - } - }, - "/api/v1/integration/obligations/{period}/ready": { - "patch": { - "operationId": "integration-mark_integration_obligation_ready", - "parameters": [ - { - "description": "Billing period in YYYY-MM format. Full obligation keys are temporarily accepted for client migration.", - "in": "path", - "name": "period", - "required": true, - "schema": { - "description": "Billing period in YYYY-MM format. Full obligation keys are temporarily accepted for client migration.", - "examples": [ - "2026-09" - ], - "title": "Period", - "type": "string" - } - } - ], - "responses": { - "200": { + "description": "Bad Request" + }, + "401": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ObligationPublic" + "$ref": "#/components/schemas/ApiErrorResponse" } } }, - "description": "Successful Response" + "description": "Unauthorized" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Forbidden" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Not Found" + }, + "409": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Conflict" + }, + "413": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Content Too Large" }, "422": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/HTTPValidationError" + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Unprocessable Content" + }, + "500": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Internal Server Error" + }, + "503": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" } } }, - "description": "Validation Error" + "description": "Service Unavailable" } }, "security": [ @@ -2129,15 +3514,95 @@ }, "description": "Successful Response" }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Bad Request" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Unauthorized" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Forbidden" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Not Found" + }, + "409": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Conflict" + }, + "413": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Content Too Large" + }, "422": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/HTTPValidationError" + "$ref": "#/components/schemas/ApiErrorResponse" } } }, - "description": "Validation Error" + "description": "Unprocessable Content" + }, + "500": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Internal Server Error" + }, + "503": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Service Unavailable" } }, "security": [ @@ -2175,6 +3640,46 @@ }, "description": "Successful Response" }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Bad Request" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Unauthorized" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Forbidden" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Not Found" + }, "409": { "content": { "application/json": { @@ -2185,15 +3690,45 @@ }, "description": "Integration run conflict" }, + "413": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Content Too Large" + }, "422": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/HTTPValidationError" + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Unprocessable Content" + }, + "500": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" } } }, - "description": "Validation Error" + "description": "Internal Server Error" + }, + "503": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Service Unavailable" } }, "security": [ @@ -2231,6 +3766,46 @@ }, "description": "Successful Response" }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Bad Request" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Unauthorized" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Forbidden" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Not Found" + }, "409": { "content": { "application/json": { @@ -2241,15 +3816,45 @@ }, "description": "Integration run conflict" }, + "413": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Content Too Large" + }, "422": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/HTTPValidationError" + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Unprocessable Content" + }, + "500": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" + } + } + }, + "description": "Internal Server Error" + }, + "503": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiErrorResponse" } } }, - "description": "Validation Error" + "description": "Service Unavailable" } }, "security": [ diff --git a/src/oblidog_client/client.py b/src/oblidog_client/client.py index 9504ff2..7330e9a 100644 --- a/src/oblidog_client/client.py +++ b/src/oblidog_client/client.py @@ -3,9 +3,11 @@ import datetime import logging import uuid +from collections.abc import Callable from typing import Any, Self from .exceptions import OblidogApiError, OblidogConflictError, OblidogValidationError +from .generated import errors from .generated.api.integration import ( integration_append_integration_obligation_note as append_note_api, ) @@ -64,7 +66,6 @@ from .generated.models.category_data_record_public import CategoryDataRecordPublic from .generated.models.category_data_records_public import CategoryDataRecordsPublic from .generated.models.category_data_schema_public import CategoryDataSchemaPublic -from .generated.models.http_validation_error import HTTPValidationError from .generated.models.integration_category_data_record_create import ( IntegrationCategoryDataRecordCreate, ) @@ -93,20 +94,33 @@ from .generated.models.obligation_note_append import ObligationNoteAppend from .generated.models.obligation_public import ObligationPublic from .generated.models.obligations_public import ObligationsPublic -from .generated.types import UNSET +from .generated.types import UNSET, Response from .period import ObligationPeriod logger = logging.getLogger(__name__) -def _result(value: Any) -> Any: - if isinstance(value, IntegrationConflictResponse): - raise OblidogConflictError(value.detail.code) - if isinstance(value, HTTPValidationError): - raise OblidogValidationError(str(value.to_dict())) - if value is None: - raise OblidogApiError(0, b"API returned no parsed response") - return value +def _request(operation: Callable[..., Response[Any]], *args: Any, **kwargs: Any) -> Any: + """Translate detailed endpoint responses into public results or SDK errors.""" + try: + response = operation(*args, **kwargs) + except errors.UnexpectedStatus as exc: + raise OblidogApiError(exc.status_code, exc.content) from exc + if response.status_code >= 400: + if isinstance(response.parsed, IntegrationConflictResponse): + raise OblidogConflictError( + response.parsed.detail.code, content=response.content + ) + if response.status_code == 422: + raise OblidogValidationError( + response.content.decode(errors="replace"), + status_code=response.status_code, + content=response.content, + ) + raise OblidogApiError(response.status_code, response.content) + if response.parsed is None: + raise OblidogApiError(response.status_code, response.content) + return response.parsed def _period_path(period: ObligationPeriod) -> str: @@ -147,13 +161,13 @@ def list( OblidogValidationError: If a supplied filter is invalid. OblidogApiError: If the API returns no parsed response. """ - result = list_api.sync( + return _request( + list_api.sync_detailed, client=self._client, year=year if year is not None else UNSET, month=month if month is not None else UNSET, lifecycle=lifecycle if lifecycle is not None else UNSET, ) - return _result(result) def get(self, period: ObligationPeriod) -> ObligationPublic: """Return one obligation for ``period`` in the key-bound category. @@ -162,12 +176,14 @@ def get(self, period: ObligationPeriod) -> ObligationPublic: TypeError: If ``period`` is not an :class:`ObligationPeriod`. OblidogApiError: If the API cannot return a parsed obligation. """ - return _result(get_api.sync(_period_path(period), client=self._client)) + return _request( + get_api.sync_detailed, _period_path(period), client=self._client + ) def list_components(self, period: ObligationPeriod) -> ObligationComponentsPublic: """List components currently attached to an obligation.""" - return _result( - list_components_api.sync(_period_path(period), client=self._client) + return _request( + list_components_api.sync_detailed, _period_path(period), client=self._client ) def upsert_component( @@ -204,10 +220,11 @@ def upsert_component( else metadata ), ) - return _result( - upsert_component_api.sync( - _period_path(period), client=self._client, body=body - ) + return _request( + upsert_component_api.sync_detailed, + _period_path(period), + client=self._client, + body=body, ) def update( @@ -235,39 +252,51 @@ def update( due_date=due_date, issue_date=issue_date, ) - return _result( - update_api.sync(_period_path(period), client=self._client, body=body) + return _request( + update_api.sync_detailed, + _period_path(period), + client=self._client, + body=body, ) def append_note(self, period: ObligationPeriod, text: str) -> ObligationPublic: """Append ``text`` to an obligation's existing notes and return it.""" - return _result( - append_note_api.sync( - _period_path(period), - client=self._client, - body=ObligationNoteAppend(text=text), - ) + return _request( + append_note_api.sync_detailed, + _period_path(period), + client=self._client, + body=ObligationNoteAppend(text=text), ) def mark_ready(self, period: ObligationPeriod) -> ObligationPublic: """Mark an obligation ready for payment.""" - return _result(mark_ready_api.sync(_period_path(period), client=self._client)) + return _request( + mark_ready_api.sync_detailed, _period_path(period), client=self._client + ) def mark_paid(self, period: ObligationPeriod) -> ObligationPublic: """Mark an obligation paid.""" - return _result(mark_paid_api.sync(_period_path(period), client=self._client)) + return _request( + mark_paid_api.sync_detailed, _period_path(period), client=self._client + ) def cancel(self, period: ObligationPeriod) -> ObligationPublic: """Cancel an obligation.""" - return _result(cancel_api.sync(_period_path(period), client=self._client)) + return _request( + cancel_api.sync_detailed, _period_path(period), client=self._client + ) def reopen(self, period: ObligationPeriod) -> ObligationPublic: """Reopen a cancelled or completed obligation.""" - return _result(reopen_api.sync(_period_path(period), client=self._client)) + return _request( + reopen_api.sync_detailed, _period_path(period), client=self._client + ) def mark_error(self, period: ObligationPeriod) -> ObligationPublic: """Mark an obligation as requiring attention after an integration error.""" - return _result(mark_error_api.sync(_period_path(period), client=self._client)) + return _request( + mark_error_api.sync_detailed, _period_path(period), client=self._client + ) class CategoryDataClient: @@ -278,7 +307,7 @@ def __init__(self, client: AuthenticatedClient) -> None: def schema(self) -> CategoryDataSchemaPublic: """Return the active schema used to validate category observations.""" - return _result(schema_category_data_api.sync(client=self._client)) + return _request(schema_category_data_api.sync_detailed, client=self._client) def list( self, @@ -293,19 +322,18 @@ def list( ``from_`` and ``to`` are inclusive API filters when supplied. Omit either one to leave that end of the range unbounded. """ - return _result( - list_category_data_api.sync( - client=self._client, - from_=from_ if from_ is not None else UNSET, - to=to if to is not None else UNSET, - limit=limit, - offset=offset, - ) + return _request( + list_category_data_api.sync_detailed, + client=self._client, + from_=from_ if from_ is not None else UNSET, + to=to if to is not None else UNSET, + limit=limit, + offset=offset, ) def latest(self) -> CategoryDataRecordPublic: """Return the latest category observation.""" - return _result(latest_category_data_api.sync(client=self._client)) + return _request(latest_category_data_api.sync_detailed, client=self._client) def create( self, @@ -334,7 +362,9 @@ def create( data=IntegrationCategoryDataRecordCreateData.from_dict(data), external_id=external_id, ) - return _result(create_category_data_api.sync(client=self._client, body=body)) + return _request( + create_category_data_api.sync_detailed, client=self._client, body=body + ) class IntegrationRun: @@ -451,7 +481,7 @@ def context(self) -> IntegrationContextPublic: the API key. Its current revision is used by :meth:`run` for optimistic locking. """ - return _result(read_context_api.sync(client=self._client)) + return _request(read_context_api.sync_detailed, client=self._client) def run(self) -> IntegrationRun: """Fetch context and start a run before synchronization work begins. @@ -499,13 +529,12 @@ def start( OblidogConflictError: If the revision is stale or a run conflicts. OblidogValidationError: If the request is invalid. """ - return _result( - start_run_api.sync( - client=self._client, - body=IntegrationRunStart( - run_id=run_id, expected_revision=expected_revision - ), - ) + return _request( + start_run_api.sync_detailed, + client=self._client, + body=IntegrationRunStart( + run_id=run_id, expected_revision=expected_revision + ), ) def finish( @@ -526,16 +555,15 @@ def finish( OblidogConflictError: If the run cannot be completed in its state. OblidogValidationError: If the completion request is invalid. """ - return _result( - finish_run_api.sync( - client=self._client, - body=IntegrationRunFinish( - run_id=run_id, - result=result, - changes_detected=changes_detected, - error=error, - ), - ) + return _request( + finish_run_api.sync_detailed, + client=self._client, + body=IntegrationRunFinish( + run_id=run_id, + result=result, + changes_detected=changes_detected, + error=error, + ), ) @@ -550,6 +578,11 @@ class OblidogClient: The client is a context manager; exiting it closes the underlying HTTP connection pool. Its ``obligations``, ``category_data``, and ``integrations`` attributes expose the supported SDK operations. + + HTTP errors raise public SDK exceptions: ``OblidogValidationError`` for + HTTP 422, ``OblidogConflictError`` for typed integration run conflicts, + and ``OblidogApiError`` for other errors. Exceptions preserve the original + ``status_code`` and response bytes in ``content``. """ def __init__( diff --git a/src/oblidog_client/exceptions.py b/src/oblidog_client/exceptions.py index 9b9d9b1..bc3fcbc 100644 --- a/src/oblidog_client/exceptions.py +++ b/src/oblidog_client/exceptions.py @@ -31,12 +31,30 @@ def __init__(self, status_code: int, content: bytes = b"") -> None: class OblidogValidationError(OblidogError): - """The Oblidog API rejected request parameters or payload.""" + """The API rejected request parameters or payload with HTTP 422. + + ``status_code`` and ``content`` preserve the original HTTP error response. + """ + + def __init__( + self, message: str, *, status_code: int = 422, content: bytes = b"" + ) -> None: + self.status_code = status_code + self.content = content + super().__init__(message) class OblidogConflictError(OblidogApiError): - """A registry operation conflicted with the current state or revision.""" + """A registry operation conflicted with the current state or revision. + + ``code`` retains the typed integration conflict reason. ``content`` keeps + the complete response body, including top-level error metadata and params. + """ - def __init__(self, code: IntegrationConflictCode) -> None: + def __init__( + self, code: IntegrationConflictCode, *, content: bytes | None = None + ) -> None: self.code = code - super().__init__(409, json.dumps({"detail": {"code": code.value}}).encode()) + if content is None: + content = json.dumps({"detail": {"code": code.value}}).encode() + super().__init__(409, content) diff --git a/src/oblidog_client/generated/api/integration/integration_append_integration_obligation_note.py b/src/oblidog_client/generated/api/integration/integration_append_integration_obligation_note.py index adf7622..0e106f5 100644 --- a/src/oblidog_client/generated/api/integration/integration_append_integration_obligation_note.py +++ b/src/oblidog_client/generated/api/integration/integration_append_integration_obligation_note.py @@ -6,7 +6,7 @@ from ... import errors from ...client import AuthenticatedClient, Client -from ...models.http_validation_error import HTTPValidationError +from ...models.api_error_response import ApiErrorResponse from ...models.obligation_note_append import ObligationNoteAppend from ...models.obligation_public import ObligationPublic from ...types import Response @@ -36,17 +36,57 @@ def _get_kwargs( def _parse_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> HTTPValidationError | ObligationPublic | None: +) -> ApiErrorResponse | ObligationPublic | None: if response.status_code == 200: response_200 = ObligationPublic.from_dict(response.json()) return response_200 + if response.status_code == 400: + response_400 = ApiErrorResponse.from_dict(response.json()) + + return response_400 + + if response.status_code == 401: + response_401 = ApiErrorResponse.from_dict(response.json()) + + return response_401 + + if response.status_code == 403: + response_403 = ApiErrorResponse.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = ApiErrorResponse.from_dict(response.json()) + + return response_404 + + if response.status_code == 409: + response_409 = ApiErrorResponse.from_dict(response.json()) + + return response_409 + + if response.status_code == 413: + response_413 = ApiErrorResponse.from_dict(response.json()) + + return response_413 + if response.status_code == 422: - response_422 = HTTPValidationError.from_dict(response.json()) + response_422 = ApiErrorResponse.from_dict(response.json()) return response_422 + if response.status_code == 500: + response_500 = ApiErrorResponse.from_dict(response.json()) + + return response_500 + + if response.status_code == 503: + response_503 = ApiErrorResponse.from_dict(response.json()) + + return response_503 + if client.raise_on_unexpected_status: raise errors.UnexpectedStatus(response.status_code, response.content) else: @@ -55,7 +95,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[HTTPValidationError | ObligationPublic]: +) -> Response[ApiErrorResponse | ObligationPublic]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -69,7 +109,7 @@ def sync_detailed( *, client: AuthenticatedClient, body: ObligationNoteAppend, -) -> Response[HTTPValidationError | ObligationPublic]: +) -> Response[ApiErrorResponse | ObligationPublic]: """Append Integration Obligation Note Args: @@ -82,7 +122,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[HTTPValidationError | ObligationPublic] + Response[ApiErrorResponse | ObligationPublic] """ kwargs = _get_kwargs( @@ -102,7 +142,7 @@ def sync( *, client: AuthenticatedClient, body: ObligationNoteAppend, -) -> HTTPValidationError | ObligationPublic | None: +) -> ApiErrorResponse | ObligationPublic | None: """Append Integration Obligation Note Args: @@ -115,7 +155,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - HTTPValidationError | ObligationPublic + ApiErrorResponse | ObligationPublic """ return sync_detailed( @@ -130,7 +170,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient, body: ObligationNoteAppend, -) -> Response[HTTPValidationError | ObligationPublic]: +) -> Response[ApiErrorResponse | ObligationPublic]: """Append Integration Obligation Note Args: @@ -143,7 +183,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[HTTPValidationError | ObligationPublic] + Response[ApiErrorResponse | ObligationPublic] """ kwargs = _get_kwargs( @@ -161,7 +201,7 @@ async def asyncio( *, client: AuthenticatedClient, body: ObligationNoteAppend, -) -> HTTPValidationError | ObligationPublic | None: +) -> ApiErrorResponse | ObligationPublic | None: """Append Integration Obligation Note Args: @@ -174,7 +214,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - HTTPValidationError | ObligationPublic + ApiErrorResponse | ObligationPublic """ return ( diff --git a/src/oblidog_client/generated/api/integration/integration_cancel_integration_obligation.py b/src/oblidog_client/generated/api/integration/integration_cancel_integration_obligation.py index 775ca5f..8a945ec 100644 --- a/src/oblidog_client/generated/api/integration/integration_cancel_integration_obligation.py +++ b/src/oblidog_client/generated/api/integration/integration_cancel_integration_obligation.py @@ -6,7 +6,7 @@ from ... import errors from ...client import AuthenticatedClient, Client -from ...models.http_validation_error import HTTPValidationError +from ...models.api_error_response import ApiErrorResponse from ...models.obligation_public import ObligationPublic from ...types import Response @@ -27,17 +27,57 @@ def _get_kwargs( def _parse_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> HTTPValidationError | ObligationPublic | None: +) -> ApiErrorResponse | ObligationPublic | None: if response.status_code == 200: response_200 = ObligationPublic.from_dict(response.json()) return response_200 + if response.status_code == 400: + response_400 = ApiErrorResponse.from_dict(response.json()) + + return response_400 + + if response.status_code == 401: + response_401 = ApiErrorResponse.from_dict(response.json()) + + return response_401 + + if response.status_code == 403: + response_403 = ApiErrorResponse.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = ApiErrorResponse.from_dict(response.json()) + + return response_404 + + if response.status_code == 409: + response_409 = ApiErrorResponse.from_dict(response.json()) + + return response_409 + + if response.status_code == 413: + response_413 = ApiErrorResponse.from_dict(response.json()) + + return response_413 + if response.status_code == 422: - response_422 = HTTPValidationError.from_dict(response.json()) + response_422 = ApiErrorResponse.from_dict(response.json()) return response_422 + if response.status_code == 500: + response_500 = ApiErrorResponse.from_dict(response.json()) + + return response_500 + + if response.status_code == 503: + response_503 = ApiErrorResponse.from_dict(response.json()) + + return response_503 + if client.raise_on_unexpected_status: raise errors.UnexpectedStatus(response.status_code, response.content) else: @@ -46,7 +86,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[HTTPValidationError | ObligationPublic]: +) -> Response[ApiErrorResponse | ObligationPublic]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -59,7 +99,7 @@ def sync_detailed( period: str, *, client: AuthenticatedClient, -) -> Response[HTTPValidationError | ObligationPublic]: +) -> Response[ApiErrorResponse | ObligationPublic]: """Cancel Integration Obligation Args: @@ -71,7 +111,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[HTTPValidationError | ObligationPublic] + Response[ApiErrorResponse | ObligationPublic] """ kwargs = _get_kwargs( @@ -89,7 +129,7 @@ def sync( period: str, *, client: AuthenticatedClient, -) -> HTTPValidationError | ObligationPublic | None: +) -> ApiErrorResponse | ObligationPublic | None: """Cancel Integration Obligation Args: @@ -101,7 +141,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - HTTPValidationError | ObligationPublic + ApiErrorResponse | ObligationPublic """ return sync_detailed( @@ -114,7 +154,7 @@ async def asyncio_detailed( period: str, *, client: AuthenticatedClient, -) -> Response[HTTPValidationError | ObligationPublic]: +) -> Response[ApiErrorResponse | ObligationPublic]: """Cancel Integration Obligation Args: @@ -126,7 +166,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[HTTPValidationError | ObligationPublic] + Response[ApiErrorResponse | ObligationPublic] """ kwargs = _get_kwargs( @@ -142,7 +182,7 @@ async def asyncio( period: str, *, client: AuthenticatedClient, -) -> HTTPValidationError | ObligationPublic | None: +) -> ApiErrorResponse | ObligationPublic | None: """Cancel Integration Obligation Args: @@ -154,7 +194,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - HTTPValidationError | ObligationPublic + ApiErrorResponse | ObligationPublic """ return ( diff --git a/src/oblidog_client/generated/api/integration/integration_create_integration_category_data_record.py b/src/oblidog_client/generated/api/integration/integration_create_integration_category_data_record.py index 56943dc..ff9beb1 100644 --- a/src/oblidog_client/generated/api/integration/integration_create_integration_category_data_record.py +++ b/src/oblidog_client/generated/api/integration/integration_create_integration_category_data_record.py @@ -5,8 +5,8 @@ from ... import errors from ...client import AuthenticatedClient, Client +from ...models.api_error_response import ApiErrorResponse from ...models.category_data_record_public import CategoryDataRecordPublic -from ...models.http_validation_error import HTTPValidationError from ...models.integration_category_data_record_create import ( IntegrationCategoryDataRecordCreate, ) @@ -34,17 +34,57 @@ def _get_kwargs( def _parse_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> CategoryDataRecordPublic | HTTPValidationError | None: +) -> ApiErrorResponse | CategoryDataRecordPublic | None: if response.status_code == 200: response_200 = CategoryDataRecordPublic.from_dict(response.json()) return response_200 + if response.status_code == 400: + response_400 = ApiErrorResponse.from_dict(response.json()) + + return response_400 + + if response.status_code == 401: + response_401 = ApiErrorResponse.from_dict(response.json()) + + return response_401 + + if response.status_code == 403: + response_403 = ApiErrorResponse.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = ApiErrorResponse.from_dict(response.json()) + + return response_404 + + if response.status_code == 409: + response_409 = ApiErrorResponse.from_dict(response.json()) + + return response_409 + + if response.status_code == 413: + response_413 = ApiErrorResponse.from_dict(response.json()) + + return response_413 + if response.status_code == 422: - response_422 = HTTPValidationError.from_dict(response.json()) + response_422 = ApiErrorResponse.from_dict(response.json()) return response_422 + if response.status_code == 500: + response_500 = ApiErrorResponse.from_dict(response.json()) + + return response_500 + + if response.status_code == 503: + response_503 = ApiErrorResponse.from_dict(response.json()) + + return response_503 + if client.raise_on_unexpected_status: raise errors.UnexpectedStatus(response.status_code, response.content) else: @@ -53,7 +93,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[CategoryDataRecordPublic | HTTPValidationError]: +) -> Response[ApiErrorResponse | CategoryDataRecordPublic]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -66,7 +106,7 @@ def sync_detailed( *, client: AuthenticatedClient, body: IntegrationCategoryDataRecordCreate, -) -> Response[CategoryDataRecordPublic | HTTPValidationError]: +) -> Response[ApiErrorResponse | CategoryDataRecordPublic]: """Create Integration Category Data Record Args: @@ -78,7 +118,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[CategoryDataRecordPublic | HTTPValidationError] + Response[ApiErrorResponse | CategoryDataRecordPublic] """ kwargs = _get_kwargs( @@ -96,7 +136,7 @@ def sync( *, client: AuthenticatedClient, body: IntegrationCategoryDataRecordCreate, -) -> CategoryDataRecordPublic | HTTPValidationError | None: +) -> ApiErrorResponse | CategoryDataRecordPublic | None: """Create Integration Category Data Record Args: @@ -108,7 +148,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - CategoryDataRecordPublic | HTTPValidationError + ApiErrorResponse | CategoryDataRecordPublic """ return sync_detailed( @@ -121,7 +161,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient, body: IntegrationCategoryDataRecordCreate, -) -> Response[CategoryDataRecordPublic | HTTPValidationError]: +) -> Response[ApiErrorResponse | CategoryDataRecordPublic]: """Create Integration Category Data Record Args: @@ -133,7 +173,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[CategoryDataRecordPublic | HTTPValidationError] + Response[ApiErrorResponse | CategoryDataRecordPublic] """ kwargs = _get_kwargs( @@ -149,7 +189,7 @@ async def asyncio( *, client: AuthenticatedClient, body: IntegrationCategoryDataRecordCreate, -) -> CategoryDataRecordPublic | HTTPValidationError | None: +) -> ApiErrorResponse | CategoryDataRecordPublic | None: """Create Integration Category Data Record Args: @@ -161,7 +201,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - CategoryDataRecordPublic | HTTPValidationError + ApiErrorResponse | CategoryDataRecordPublic """ return ( diff --git a/src/oblidog_client/generated/api/integration/integration_finish_integration_run.py b/src/oblidog_client/generated/api/integration/integration_finish_integration_run.py index e2082b9..59e9af8 100644 --- a/src/oblidog_client/generated/api/integration/integration_finish_integration_run.py +++ b/src/oblidog_client/generated/api/integration/integration_finish_integration_run.py @@ -5,7 +5,7 @@ from ... import errors from ...client import AuthenticatedClient, Client -from ...models.http_validation_error import HTTPValidationError +from ...models.api_error_response import ApiErrorResponse from ...models.integration_conflict_response import IntegrationConflictResponse from ...models.integration_public import IntegrationPublic from ...models.integration_run_finish import IntegrationRunFinish @@ -33,22 +33,57 @@ def _get_kwargs( def _parse_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> HTTPValidationError | IntegrationConflictResponse | IntegrationPublic | None: +) -> ApiErrorResponse | IntegrationConflictResponse | IntegrationPublic | None: if response.status_code == 200: response_200 = IntegrationPublic.from_dict(response.json()) return response_200 + if response.status_code == 400: + response_400 = ApiErrorResponse.from_dict(response.json()) + + return response_400 + + if response.status_code == 401: + response_401 = ApiErrorResponse.from_dict(response.json()) + + return response_401 + + if response.status_code == 403: + response_403 = ApiErrorResponse.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = ApiErrorResponse.from_dict(response.json()) + + return response_404 + if response.status_code == 409: response_409 = IntegrationConflictResponse.from_dict(response.json()) return response_409 + if response.status_code == 413: + response_413 = ApiErrorResponse.from_dict(response.json()) + + return response_413 + if response.status_code == 422: - response_422 = HTTPValidationError.from_dict(response.json()) + response_422 = ApiErrorResponse.from_dict(response.json()) return response_422 + if response.status_code == 500: + response_500 = ApiErrorResponse.from_dict(response.json()) + + return response_500 + + if response.status_code == 503: + response_503 = ApiErrorResponse.from_dict(response.json()) + + return response_503 + if client.raise_on_unexpected_status: raise errors.UnexpectedStatus(response.status_code, response.content) else: @@ -57,7 +92,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[HTTPValidationError | IntegrationConflictResponse | IntegrationPublic]: +) -> Response[ApiErrorResponse | IntegrationConflictResponse | IntegrationPublic]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -70,7 +105,7 @@ def sync_detailed( *, client: AuthenticatedClient, body: IntegrationRunFinish, -) -> Response[HTTPValidationError | IntegrationConflictResponse | IntegrationPublic]: +) -> Response[ApiErrorResponse | IntegrationConflictResponse | IntegrationPublic]: """Finish Integration Run Args: @@ -81,7 +116,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[HTTPValidationError | IntegrationConflictResponse | IntegrationPublic] + Response[ApiErrorResponse | IntegrationConflictResponse | IntegrationPublic] """ kwargs = _get_kwargs( @@ -99,7 +134,7 @@ def sync( *, client: AuthenticatedClient, body: IntegrationRunFinish, -) -> HTTPValidationError | IntegrationConflictResponse | IntegrationPublic | None: +) -> ApiErrorResponse | IntegrationConflictResponse | IntegrationPublic | None: """Finish Integration Run Args: @@ -110,7 +145,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - HTTPValidationError | IntegrationConflictResponse | IntegrationPublic + ApiErrorResponse | IntegrationConflictResponse | IntegrationPublic """ return sync_detailed( @@ -123,7 +158,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient, body: IntegrationRunFinish, -) -> Response[HTTPValidationError | IntegrationConflictResponse | IntegrationPublic]: +) -> Response[ApiErrorResponse | IntegrationConflictResponse | IntegrationPublic]: """Finish Integration Run Args: @@ -134,7 +169,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[HTTPValidationError | IntegrationConflictResponse | IntegrationPublic] + Response[ApiErrorResponse | IntegrationConflictResponse | IntegrationPublic] """ kwargs = _get_kwargs( @@ -150,7 +185,7 @@ async def asyncio( *, client: AuthenticatedClient, body: IntegrationRunFinish, -) -> HTTPValidationError | IntegrationConflictResponse | IntegrationPublic | None: +) -> ApiErrorResponse | IntegrationConflictResponse | IntegrationPublic | None: """Finish Integration Run Args: @@ -161,7 +196,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - HTTPValidationError | IntegrationConflictResponse | IntegrationPublic + ApiErrorResponse | IntegrationConflictResponse | IntegrationPublic """ return ( diff --git a/src/oblidog_client/generated/api/integration/integration_mark_integration_obligation_error.py b/src/oblidog_client/generated/api/integration/integration_mark_integration_obligation_error.py index a9f6c63..95ad523 100644 --- a/src/oblidog_client/generated/api/integration/integration_mark_integration_obligation_error.py +++ b/src/oblidog_client/generated/api/integration/integration_mark_integration_obligation_error.py @@ -6,7 +6,7 @@ from ... import errors from ...client import AuthenticatedClient, Client -from ...models.http_validation_error import HTTPValidationError +from ...models.api_error_response import ApiErrorResponse from ...models.obligation_public import ObligationPublic from ...types import Response @@ -27,17 +27,57 @@ def _get_kwargs( def _parse_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> HTTPValidationError | ObligationPublic | None: +) -> ApiErrorResponse | ObligationPublic | None: if response.status_code == 200: response_200 = ObligationPublic.from_dict(response.json()) return response_200 + if response.status_code == 400: + response_400 = ApiErrorResponse.from_dict(response.json()) + + return response_400 + + if response.status_code == 401: + response_401 = ApiErrorResponse.from_dict(response.json()) + + return response_401 + + if response.status_code == 403: + response_403 = ApiErrorResponse.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = ApiErrorResponse.from_dict(response.json()) + + return response_404 + + if response.status_code == 409: + response_409 = ApiErrorResponse.from_dict(response.json()) + + return response_409 + + if response.status_code == 413: + response_413 = ApiErrorResponse.from_dict(response.json()) + + return response_413 + if response.status_code == 422: - response_422 = HTTPValidationError.from_dict(response.json()) + response_422 = ApiErrorResponse.from_dict(response.json()) return response_422 + if response.status_code == 500: + response_500 = ApiErrorResponse.from_dict(response.json()) + + return response_500 + + if response.status_code == 503: + response_503 = ApiErrorResponse.from_dict(response.json()) + + return response_503 + if client.raise_on_unexpected_status: raise errors.UnexpectedStatus(response.status_code, response.content) else: @@ -46,7 +86,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[HTTPValidationError | ObligationPublic]: +) -> Response[ApiErrorResponse | ObligationPublic]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -59,7 +99,7 @@ def sync_detailed( period: str, *, client: AuthenticatedClient, -) -> Response[HTTPValidationError | ObligationPublic]: +) -> Response[ApiErrorResponse | ObligationPublic]: """Mark Integration Obligation Error Args: @@ -71,7 +111,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[HTTPValidationError | ObligationPublic] + Response[ApiErrorResponse | ObligationPublic] """ kwargs = _get_kwargs( @@ -89,7 +129,7 @@ def sync( period: str, *, client: AuthenticatedClient, -) -> HTTPValidationError | ObligationPublic | None: +) -> ApiErrorResponse | ObligationPublic | None: """Mark Integration Obligation Error Args: @@ -101,7 +141,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - HTTPValidationError | ObligationPublic + ApiErrorResponse | ObligationPublic """ return sync_detailed( @@ -114,7 +154,7 @@ async def asyncio_detailed( period: str, *, client: AuthenticatedClient, -) -> Response[HTTPValidationError | ObligationPublic]: +) -> Response[ApiErrorResponse | ObligationPublic]: """Mark Integration Obligation Error Args: @@ -126,7 +166,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[HTTPValidationError | ObligationPublic] + Response[ApiErrorResponse | ObligationPublic] """ kwargs = _get_kwargs( @@ -142,7 +182,7 @@ async def asyncio( period: str, *, client: AuthenticatedClient, -) -> HTTPValidationError | ObligationPublic | None: +) -> ApiErrorResponse | ObligationPublic | None: """Mark Integration Obligation Error Args: @@ -154,7 +194,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - HTTPValidationError | ObligationPublic + ApiErrorResponse | ObligationPublic """ return ( diff --git a/src/oblidog_client/generated/api/integration/integration_mark_integration_obligation_paid.py b/src/oblidog_client/generated/api/integration/integration_mark_integration_obligation_paid.py index 379d602..dde1456 100644 --- a/src/oblidog_client/generated/api/integration/integration_mark_integration_obligation_paid.py +++ b/src/oblidog_client/generated/api/integration/integration_mark_integration_obligation_paid.py @@ -6,7 +6,7 @@ from ... import errors from ...client import AuthenticatedClient, Client -from ...models.http_validation_error import HTTPValidationError +from ...models.api_error_response import ApiErrorResponse from ...models.obligation_public import ObligationPublic from ...types import Response @@ -27,17 +27,57 @@ def _get_kwargs( def _parse_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> HTTPValidationError | ObligationPublic | None: +) -> ApiErrorResponse | ObligationPublic | None: if response.status_code == 200: response_200 = ObligationPublic.from_dict(response.json()) return response_200 + if response.status_code == 400: + response_400 = ApiErrorResponse.from_dict(response.json()) + + return response_400 + + if response.status_code == 401: + response_401 = ApiErrorResponse.from_dict(response.json()) + + return response_401 + + if response.status_code == 403: + response_403 = ApiErrorResponse.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = ApiErrorResponse.from_dict(response.json()) + + return response_404 + + if response.status_code == 409: + response_409 = ApiErrorResponse.from_dict(response.json()) + + return response_409 + + if response.status_code == 413: + response_413 = ApiErrorResponse.from_dict(response.json()) + + return response_413 + if response.status_code == 422: - response_422 = HTTPValidationError.from_dict(response.json()) + response_422 = ApiErrorResponse.from_dict(response.json()) return response_422 + if response.status_code == 500: + response_500 = ApiErrorResponse.from_dict(response.json()) + + return response_500 + + if response.status_code == 503: + response_503 = ApiErrorResponse.from_dict(response.json()) + + return response_503 + if client.raise_on_unexpected_status: raise errors.UnexpectedStatus(response.status_code, response.content) else: @@ -46,7 +86,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[HTTPValidationError | ObligationPublic]: +) -> Response[ApiErrorResponse | ObligationPublic]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -59,7 +99,7 @@ def sync_detailed( period: str, *, client: AuthenticatedClient, -) -> Response[HTTPValidationError | ObligationPublic]: +) -> Response[ApiErrorResponse | ObligationPublic]: """Mark Integration Obligation Paid Args: @@ -71,7 +111,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[HTTPValidationError | ObligationPublic] + Response[ApiErrorResponse | ObligationPublic] """ kwargs = _get_kwargs( @@ -89,7 +129,7 @@ def sync( period: str, *, client: AuthenticatedClient, -) -> HTTPValidationError | ObligationPublic | None: +) -> ApiErrorResponse | ObligationPublic | None: """Mark Integration Obligation Paid Args: @@ -101,7 +141,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - HTTPValidationError | ObligationPublic + ApiErrorResponse | ObligationPublic """ return sync_detailed( @@ -114,7 +154,7 @@ async def asyncio_detailed( period: str, *, client: AuthenticatedClient, -) -> Response[HTTPValidationError | ObligationPublic]: +) -> Response[ApiErrorResponse | ObligationPublic]: """Mark Integration Obligation Paid Args: @@ -126,7 +166,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[HTTPValidationError | ObligationPublic] + Response[ApiErrorResponse | ObligationPublic] """ kwargs = _get_kwargs( @@ -142,7 +182,7 @@ async def asyncio( period: str, *, client: AuthenticatedClient, -) -> HTTPValidationError | ObligationPublic | None: +) -> ApiErrorResponse | ObligationPublic | None: """Mark Integration Obligation Paid Args: @@ -154,7 +194,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - HTTPValidationError | ObligationPublic + ApiErrorResponse | ObligationPublic """ return ( diff --git a/src/oblidog_client/generated/api/integration/integration_mark_integration_obligation_ready.py b/src/oblidog_client/generated/api/integration/integration_mark_integration_obligation_ready.py index 18b5e78..4d78c59 100644 --- a/src/oblidog_client/generated/api/integration/integration_mark_integration_obligation_ready.py +++ b/src/oblidog_client/generated/api/integration/integration_mark_integration_obligation_ready.py @@ -6,7 +6,7 @@ from ... import errors from ...client import AuthenticatedClient, Client -from ...models.http_validation_error import HTTPValidationError +from ...models.api_error_response import ApiErrorResponse from ...models.obligation_public import ObligationPublic from ...types import Response @@ -27,17 +27,57 @@ def _get_kwargs( def _parse_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> HTTPValidationError | ObligationPublic | None: +) -> ApiErrorResponse | ObligationPublic | None: if response.status_code == 200: response_200 = ObligationPublic.from_dict(response.json()) return response_200 + if response.status_code == 400: + response_400 = ApiErrorResponse.from_dict(response.json()) + + return response_400 + + if response.status_code == 401: + response_401 = ApiErrorResponse.from_dict(response.json()) + + return response_401 + + if response.status_code == 403: + response_403 = ApiErrorResponse.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = ApiErrorResponse.from_dict(response.json()) + + return response_404 + + if response.status_code == 409: + response_409 = ApiErrorResponse.from_dict(response.json()) + + return response_409 + + if response.status_code == 413: + response_413 = ApiErrorResponse.from_dict(response.json()) + + return response_413 + if response.status_code == 422: - response_422 = HTTPValidationError.from_dict(response.json()) + response_422 = ApiErrorResponse.from_dict(response.json()) return response_422 + if response.status_code == 500: + response_500 = ApiErrorResponse.from_dict(response.json()) + + return response_500 + + if response.status_code == 503: + response_503 = ApiErrorResponse.from_dict(response.json()) + + return response_503 + if client.raise_on_unexpected_status: raise errors.UnexpectedStatus(response.status_code, response.content) else: @@ -46,7 +86,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[HTTPValidationError | ObligationPublic]: +) -> Response[ApiErrorResponse | ObligationPublic]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -59,7 +99,7 @@ def sync_detailed( period: str, *, client: AuthenticatedClient, -) -> Response[HTTPValidationError | ObligationPublic]: +) -> Response[ApiErrorResponse | ObligationPublic]: """Mark Integration Obligation Ready Args: @@ -71,7 +111,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[HTTPValidationError | ObligationPublic] + Response[ApiErrorResponse | ObligationPublic] """ kwargs = _get_kwargs( @@ -89,7 +129,7 @@ def sync( period: str, *, client: AuthenticatedClient, -) -> HTTPValidationError | ObligationPublic | None: +) -> ApiErrorResponse | ObligationPublic | None: """Mark Integration Obligation Ready Args: @@ -101,7 +141,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - HTTPValidationError | ObligationPublic + ApiErrorResponse | ObligationPublic """ return sync_detailed( @@ -114,7 +154,7 @@ async def asyncio_detailed( period: str, *, client: AuthenticatedClient, -) -> Response[HTTPValidationError | ObligationPublic]: +) -> Response[ApiErrorResponse | ObligationPublic]: """Mark Integration Obligation Ready Args: @@ -126,7 +166,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[HTTPValidationError | ObligationPublic] + Response[ApiErrorResponse | ObligationPublic] """ kwargs = _get_kwargs( @@ -142,7 +182,7 @@ async def asyncio( period: str, *, client: AuthenticatedClient, -) -> HTTPValidationError | ObligationPublic | None: +) -> ApiErrorResponse | ObligationPublic | None: """Mark Integration Obligation Ready Args: @@ -154,7 +194,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - HTTPValidationError | ObligationPublic + ApiErrorResponse | ObligationPublic """ return ( diff --git a/src/oblidog_client/generated/api/integration/integration_read_integration_category_data_records.py b/src/oblidog_client/generated/api/integration/integration_read_integration_category_data_records.py index 39b9601..944d8fe 100644 --- a/src/oblidog_client/generated/api/integration/integration_read_integration_category_data_records.py +++ b/src/oblidog_client/generated/api/integration/integration_read_integration_category_data_records.py @@ -6,8 +6,8 @@ from ... import errors from ...client import AuthenticatedClient, Client +from ...models.api_error_response import ApiErrorResponse from ...models.category_data_records_public import CategoryDataRecordsPublic -from ...models.http_validation_error import HTTPValidationError from ...types import UNSET, Response, Unset @@ -56,17 +56,57 @@ def _get_kwargs( def _parse_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> CategoryDataRecordsPublic | HTTPValidationError | None: +) -> ApiErrorResponse | CategoryDataRecordsPublic | None: if response.status_code == 200: response_200 = CategoryDataRecordsPublic.from_dict(response.json()) return response_200 + if response.status_code == 400: + response_400 = ApiErrorResponse.from_dict(response.json()) + + return response_400 + + if response.status_code == 401: + response_401 = ApiErrorResponse.from_dict(response.json()) + + return response_401 + + if response.status_code == 403: + response_403 = ApiErrorResponse.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = ApiErrorResponse.from_dict(response.json()) + + return response_404 + + if response.status_code == 409: + response_409 = ApiErrorResponse.from_dict(response.json()) + + return response_409 + + if response.status_code == 413: + response_413 = ApiErrorResponse.from_dict(response.json()) + + return response_413 + if response.status_code == 422: - response_422 = HTTPValidationError.from_dict(response.json()) + response_422 = ApiErrorResponse.from_dict(response.json()) return response_422 + if response.status_code == 500: + response_500 = ApiErrorResponse.from_dict(response.json()) + + return response_500 + + if response.status_code == 503: + response_503 = ApiErrorResponse.from_dict(response.json()) + + return response_503 + if client.raise_on_unexpected_status: raise errors.UnexpectedStatus(response.status_code, response.content) else: @@ -75,7 +115,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[CategoryDataRecordsPublic | HTTPValidationError]: +) -> Response[ApiErrorResponse | CategoryDataRecordsPublic]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -91,7 +131,7 @@ def sync_detailed( to: datetime.datetime | None | Unset = UNSET, limit: int | Unset = 100, offset: int | Unset = 0, -) -> Response[CategoryDataRecordsPublic | HTTPValidationError]: +) -> Response[ApiErrorResponse | CategoryDataRecordsPublic]: """Read Integration Category Data Records Args: @@ -105,7 +145,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[CategoryDataRecordsPublic | HTTPValidationError] + Response[ApiErrorResponse | CategoryDataRecordsPublic] """ kwargs = _get_kwargs( @@ -129,7 +169,7 @@ def sync( to: datetime.datetime | None | Unset = UNSET, limit: int | Unset = 100, offset: int | Unset = 0, -) -> CategoryDataRecordsPublic | HTTPValidationError | None: +) -> ApiErrorResponse | CategoryDataRecordsPublic | None: """Read Integration Category Data Records Args: @@ -143,7 +183,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - CategoryDataRecordsPublic | HTTPValidationError + ApiErrorResponse | CategoryDataRecordsPublic """ return sync_detailed( @@ -162,7 +202,7 @@ async def asyncio_detailed( to: datetime.datetime | None | Unset = UNSET, limit: int | Unset = 100, offset: int | Unset = 0, -) -> Response[CategoryDataRecordsPublic | HTTPValidationError]: +) -> Response[ApiErrorResponse | CategoryDataRecordsPublic]: """Read Integration Category Data Records Args: @@ -176,7 +216,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[CategoryDataRecordsPublic | HTTPValidationError] + Response[ApiErrorResponse | CategoryDataRecordsPublic] """ kwargs = _get_kwargs( @@ -198,7 +238,7 @@ async def asyncio( to: datetime.datetime | None | Unset = UNSET, limit: int | Unset = 100, offset: int | Unset = 0, -) -> CategoryDataRecordsPublic | HTTPValidationError | None: +) -> ApiErrorResponse | CategoryDataRecordsPublic | None: """Read Integration Category Data Records Args: @@ -212,7 +252,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - CategoryDataRecordsPublic | HTTPValidationError + ApiErrorResponse | CategoryDataRecordsPublic """ return ( diff --git a/src/oblidog_client/generated/api/integration/integration_read_integration_category_data_schema.py b/src/oblidog_client/generated/api/integration/integration_read_integration_category_data_schema.py index d97de41..ff7f38c 100644 --- a/src/oblidog_client/generated/api/integration/integration_read_integration_category_data_schema.py +++ b/src/oblidog_client/generated/api/integration/integration_read_integration_category_data_schema.py @@ -5,6 +5,7 @@ from ... import errors from ...client import AuthenticatedClient, Client +from ...models.api_error_response import ApiErrorResponse from ...models.category_data_schema_public import CategoryDataSchemaPublic from ...types import Response @@ -21,12 +22,57 @@ def _get_kwargs() -> dict[str, Any]: def _parse_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> CategoryDataSchemaPublic | None: +) -> ApiErrorResponse | CategoryDataSchemaPublic | None: if response.status_code == 200: response_200 = CategoryDataSchemaPublic.from_dict(response.json()) return response_200 + if response.status_code == 400: + response_400 = ApiErrorResponse.from_dict(response.json()) + + return response_400 + + if response.status_code == 401: + response_401 = ApiErrorResponse.from_dict(response.json()) + + return response_401 + + if response.status_code == 403: + response_403 = ApiErrorResponse.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = ApiErrorResponse.from_dict(response.json()) + + return response_404 + + if response.status_code == 409: + response_409 = ApiErrorResponse.from_dict(response.json()) + + return response_409 + + if response.status_code == 413: + response_413 = ApiErrorResponse.from_dict(response.json()) + + return response_413 + + if response.status_code == 422: + response_422 = ApiErrorResponse.from_dict(response.json()) + + return response_422 + + if response.status_code == 500: + response_500 = ApiErrorResponse.from_dict(response.json()) + + return response_500 + + if response.status_code == 503: + response_503 = ApiErrorResponse.from_dict(response.json()) + + return response_503 + if client.raise_on_unexpected_status: raise errors.UnexpectedStatus(response.status_code, response.content) else: @@ -35,7 +81,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[CategoryDataSchemaPublic]: +) -> Response[ApiErrorResponse | CategoryDataSchemaPublic]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -47,7 +93,7 @@ def _build_response( def sync_detailed( *, client: AuthenticatedClient, -) -> Response[CategoryDataSchemaPublic]: +) -> Response[ApiErrorResponse | CategoryDataSchemaPublic]: """Read Integration Category Data Schema Raises: @@ -55,7 +101,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[CategoryDataSchemaPublic] + Response[ApiErrorResponse | CategoryDataSchemaPublic] """ kwargs = _get_kwargs() @@ -70,7 +116,7 @@ def sync_detailed( def sync( *, client: AuthenticatedClient, -) -> CategoryDataSchemaPublic | None: +) -> ApiErrorResponse | CategoryDataSchemaPublic | None: """Read Integration Category Data Schema Raises: @@ -78,7 +124,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - CategoryDataSchemaPublic + ApiErrorResponse | CategoryDataSchemaPublic """ return sync_detailed( @@ -89,7 +135,7 @@ def sync( async def asyncio_detailed( *, client: AuthenticatedClient, -) -> Response[CategoryDataSchemaPublic]: +) -> Response[ApiErrorResponse | CategoryDataSchemaPublic]: """Read Integration Category Data Schema Raises: @@ -97,7 +143,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[CategoryDataSchemaPublic] + Response[ApiErrorResponse | CategoryDataSchemaPublic] """ kwargs = _get_kwargs() @@ -110,7 +156,7 @@ async def asyncio_detailed( async def asyncio( *, client: AuthenticatedClient, -) -> CategoryDataSchemaPublic | None: +) -> ApiErrorResponse | CategoryDataSchemaPublic | None: """Read Integration Category Data Schema Raises: @@ -118,7 +164,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - CategoryDataSchemaPublic + ApiErrorResponse | CategoryDataSchemaPublic """ return ( diff --git a/src/oblidog_client/generated/api/integration/integration_read_integration_context.py b/src/oblidog_client/generated/api/integration/integration_read_integration_context.py index 306ab97..34ee6b7 100644 --- a/src/oblidog_client/generated/api/integration/integration_read_integration_context.py +++ b/src/oblidog_client/generated/api/integration/integration_read_integration_context.py @@ -5,6 +5,7 @@ from ... import errors from ...client import AuthenticatedClient, Client +from ...models.api_error_response import ApiErrorResponse from ...models.integration_context_public import IntegrationContextPublic from ...types import Response @@ -21,12 +22,57 @@ def _get_kwargs() -> dict[str, Any]: def _parse_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> IntegrationContextPublic | None: +) -> ApiErrorResponse | IntegrationContextPublic | None: if response.status_code == 200: response_200 = IntegrationContextPublic.from_dict(response.json()) return response_200 + if response.status_code == 400: + response_400 = ApiErrorResponse.from_dict(response.json()) + + return response_400 + + if response.status_code == 401: + response_401 = ApiErrorResponse.from_dict(response.json()) + + return response_401 + + if response.status_code == 403: + response_403 = ApiErrorResponse.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = ApiErrorResponse.from_dict(response.json()) + + return response_404 + + if response.status_code == 409: + response_409 = ApiErrorResponse.from_dict(response.json()) + + return response_409 + + if response.status_code == 413: + response_413 = ApiErrorResponse.from_dict(response.json()) + + return response_413 + + if response.status_code == 422: + response_422 = ApiErrorResponse.from_dict(response.json()) + + return response_422 + + if response.status_code == 500: + response_500 = ApiErrorResponse.from_dict(response.json()) + + return response_500 + + if response.status_code == 503: + response_503 = ApiErrorResponse.from_dict(response.json()) + + return response_503 + if client.raise_on_unexpected_status: raise errors.UnexpectedStatus(response.status_code, response.content) else: @@ -35,7 +81,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[IntegrationContextPublic]: +) -> Response[ApiErrorResponse | IntegrationContextPublic]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -47,7 +93,7 @@ def _build_response( def sync_detailed( *, client: AuthenticatedClient, -) -> Response[IntegrationContextPublic]: +) -> Response[ApiErrorResponse | IntegrationContextPublic]: """Read Integration Context Raises: @@ -55,7 +101,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[IntegrationContextPublic] + Response[ApiErrorResponse | IntegrationContextPublic] """ kwargs = _get_kwargs() @@ -70,7 +116,7 @@ def sync_detailed( def sync( *, client: AuthenticatedClient, -) -> IntegrationContextPublic | None: +) -> ApiErrorResponse | IntegrationContextPublic | None: """Read Integration Context Raises: @@ -78,7 +124,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - IntegrationContextPublic + ApiErrorResponse | IntegrationContextPublic """ return sync_detailed( @@ -89,7 +135,7 @@ def sync( async def asyncio_detailed( *, client: AuthenticatedClient, -) -> Response[IntegrationContextPublic]: +) -> Response[ApiErrorResponse | IntegrationContextPublic]: """Read Integration Context Raises: @@ -97,7 +143,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[IntegrationContextPublic] + Response[ApiErrorResponse | IntegrationContextPublic] """ kwargs = _get_kwargs() @@ -110,7 +156,7 @@ async def asyncio_detailed( async def asyncio( *, client: AuthenticatedClient, -) -> IntegrationContextPublic | None: +) -> ApiErrorResponse | IntegrationContextPublic | None: """Read Integration Context Raises: @@ -118,7 +164,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - IntegrationContextPublic + ApiErrorResponse | IntegrationContextPublic """ return ( diff --git a/src/oblidog_client/generated/api/integration/integration_read_integration_obligation.py b/src/oblidog_client/generated/api/integration/integration_read_integration_obligation.py index 7192bd7..de7e9bf 100644 --- a/src/oblidog_client/generated/api/integration/integration_read_integration_obligation.py +++ b/src/oblidog_client/generated/api/integration/integration_read_integration_obligation.py @@ -6,7 +6,7 @@ from ... import errors from ...client import AuthenticatedClient, Client -from ...models.http_validation_error import HTTPValidationError +from ...models.api_error_response import ApiErrorResponse from ...models.obligation_public import ObligationPublic from ...types import Response @@ -27,17 +27,57 @@ def _get_kwargs( def _parse_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> HTTPValidationError | ObligationPublic | None: +) -> ApiErrorResponse | ObligationPublic | None: if response.status_code == 200: response_200 = ObligationPublic.from_dict(response.json()) return response_200 + if response.status_code == 400: + response_400 = ApiErrorResponse.from_dict(response.json()) + + return response_400 + + if response.status_code == 401: + response_401 = ApiErrorResponse.from_dict(response.json()) + + return response_401 + + if response.status_code == 403: + response_403 = ApiErrorResponse.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = ApiErrorResponse.from_dict(response.json()) + + return response_404 + + if response.status_code == 409: + response_409 = ApiErrorResponse.from_dict(response.json()) + + return response_409 + + if response.status_code == 413: + response_413 = ApiErrorResponse.from_dict(response.json()) + + return response_413 + if response.status_code == 422: - response_422 = HTTPValidationError.from_dict(response.json()) + response_422 = ApiErrorResponse.from_dict(response.json()) return response_422 + if response.status_code == 500: + response_500 = ApiErrorResponse.from_dict(response.json()) + + return response_500 + + if response.status_code == 503: + response_503 = ApiErrorResponse.from_dict(response.json()) + + return response_503 + if client.raise_on_unexpected_status: raise errors.UnexpectedStatus(response.status_code, response.content) else: @@ -46,7 +86,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[HTTPValidationError | ObligationPublic]: +) -> Response[ApiErrorResponse | ObligationPublic]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -59,7 +99,7 @@ def sync_detailed( period: str, *, client: AuthenticatedClient, -) -> Response[HTTPValidationError | ObligationPublic]: +) -> Response[ApiErrorResponse | ObligationPublic]: """Read Integration Obligation Args: @@ -71,7 +111,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[HTTPValidationError | ObligationPublic] + Response[ApiErrorResponse | ObligationPublic] """ kwargs = _get_kwargs( @@ -89,7 +129,7 @@ def sync( period: str, *, client: AuthenticatedClient, -) -> HTTPValidationError | ObligationPublic | None: +) -> ApiErrorResponse | ObligationPublic | None: """Read Integration Obligation Args: @@ -101,7 +141,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - HTTPValidationError | ObligationPublic + ApiErrorResponse | ObligationPublic """ return sync_detailed( @@ -114,7 +154,7 @@ async def asyncio_detailed( period: str, *, client: AuthenticatedClient, -) -> Response[HTTPValidationError | ObligationPublic]: +) -> Response[ApiErrorResponse | ObligationPublic]: """Read Integration Obligation Args: @@ -126,7 +166,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[HTTPValidationError | ObligationPublic] + Response[ApiErrorResponse | ObligationPublic] """ kwargs = _get_kwargs( @@ -142,7 +182,7 @@ async def asyncio( period: str, *, client: AuthenticatedClient, -) -> HTTPValidationError | ObligationPublic | None: +) -> ApiErrorResponse | ObligationPublic | None: """Read Integration Obligation Args: @@ -154,7 +194,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - HTTPValidationError | ObligationPublic + ApiErrorResponse | ObligationPublic """ return ( diff --git a/src/oblidog_client/generated/api/integration/integration_read_integration_obligation_components.py b/src/oblidog_client/generated/api/integration/integration_read_integration_obligation_components.py index 751b253..c4e0792 100644 --- a/src/oblidog_client/generated/api/integration/integration_read_integration_obligation_components.py +++ b/src/oblidog_client/generated/api/integration/integration_read_integration_obligation_components.py @@ -6,7 +6,7 @@ from ... import errors from ...client import AuthenticatedClient, Client -from ...models.http_validation_error import HTTPValidationError +from ...models.api_error_response import ApiErrorResponse from ...models.obligation_components_public import ObligationComponentsPublic from ...types import Response @@ -27,17 +27,57 @@ def _get_kwargs( def _parse_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> HTTPValidationError | ObligationComponentsPublic | None: +) -> ApiErrorResponse | ObligationComponentsPublic | None: if response.status_code == 200: response_200 = ObligationComponentsPublic.from_dict(response.json()) return response_200 + if response.status_code == 400: + response_400 = ApiErrorResponse.from_dict(response.json()) + + return response_400 + + if response.status_code == 401: + response_401 = ApiErrorResponse.from_dict(response.json()) + + return response_401 + + if response.status_code == 403: + response_403 = ApiErrorResponse.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = ApiErrorResponse.from_dict(response.json()) + + return response_404 + + if response.status_code == 409: + response_409 = ApiErrorResponse.from_dict(response.json()) + + return response_409 + + if response.status_code == 413: + response_413 = ApiErrorResponse.from_dict(response.json()) + + return response_413 + if response.status_code == 422: - response_422 = HTTPValidationError.from_dict(response.json()) + response_422 = ApiErrorResponse.from_dict(response.json()) return response_422 + if response.status_code == 500: + response_500 = ApiErrorResponse.from_dict(response.json()) + + return response_500 + + if response.status_code == 503: + response_503 = ApiErrorResponse.from_dict(response.json()) + + return response_503 + if client.raise_on_unexpected_status: raise errors.UnexpectedStatus(response.status_code, response.content) else: @@ -46,7 +86,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[HTTPValidationError | ObligationComponentsPublic]: +) -> Response[ApiErrorResponse | ObligationComponentsPublic]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -59,7 +99,7 @@ def sync_detailed( period: str, *, client: AuthenticatedClient, -) -> Response[HTTPValidationError | ObligationComponentsPublic]: +) -> Response[ApiErrorResponse | ObligationComponentsPublic]: """Read Integration Obligation Components Args: @@ -71,7 +111,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[HTTPValidationError | ObligationComponentsPublic] + Response[ApiErrorResponse | ObligationComponentsPublic] """ kwargs = _get_kwargs( @@ -89,7 +129,7 @@ def sync( period: str, *, client: AuthenticatedClient, -) -> HTTPValidationError | ObligationComponentsPublic | None: +) -> ApiErrorResponse | ObligationComponentsPublic | None: """Read Integration Obligation Components Args: @@ -101,7 +141,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - HTTPValidationError | ObligationComponentsPublic + ApiErrorResponse | ObligationComponentsPublic """ return sync_detailed( @@ -114,7 +154,7 @@ async def asyncio_detailed( period: str, *, client: AuthenticatedClient, -) -> Response[HTTPValidationError | ObligationComponentsPublic]: +) -> Response[ApiErrorResponse | ObligationComponentsPublic]: """Read Integration Obligation Components Args: @@ -126,7 +166,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[HTTPValidationError | ObligationComponentsPublic] + Response[ApiErrorResponse | ObligationComponentsPublic] """ kwargs = _get_kwargs( @@ -142,7 +182,7 @@ async def asyncio( period: str, *, client: AuthenticatedClient, -) -> HTTPValidationError | ObligationComponentsPublic | None: +) -> ApiErrorResponse | ObligationComponentsPublic | None: """Read Integration Obligation Components Args: @@ -154,7 +194,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - HTTPValidationError | ObligationComponentsPublic + ApiErrorResponse | ObligationComponentsPublic """ return ( diff --git a/src/oblidog_client/generated/api/integration/integration_read_integration_obligations.py b/src/oblidog_client/generated/api/integration/integration_read_integration_obligations.py index c053950..af3589a 100644 --- a/src/oblidog_client/generated/api/integration/integration_read_integration_obligations.py +++ b/src/oblidog_client/generated/api/integration/integration_read_integration_obligations.py @@ -5,7 +5,7 @@ from ... import errors from ...client import AuthenticatedClient, Client -from ...models.http_validation_error import HTTPValidationError +from ...models.api_error_response import ApiErrorResponse from ...models.obligation_lifecycle import ObligationLifecycle from ...models.obligations_public import ObligationsPublic from ...types import UNSET, Response, Unset @@ -56,17 +56,57 @@ def _get_kwargs( def _parse_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> HTTPValidationError | ObligationsPublic | None: +) -> ApiErrorResponse | ObligationsPublic | None: if response.status_code == 200: response_200 = ObligationsPublic.from_dict(response.json()) return response_200 + if response.status_code == 400: + response_400 = ApiErrorResponse.from_dict(response.json()) + + return response_400 + + if response.status_code == 401: + response_401 = ApiErrorResponse.from_dict(response.json()) + + return response_401 + + if response.status_code == 403: + response_403 = ApiErrorResponse.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = ApiErrorResponse.from_dict(response.json()) + + return response_404 + + if response.status_code == 409: + response_409 = ApiErrorResponse.from_dict(response.json()) + + return response_409 + + if response.status_code == 413: + response_413 = ApiErrorResponse.from_dict(response.json()) + + return response_413 + if response.status_code == 422: - response_422 = HTTPValidationError.from_dict(response.json()) + response_422 = ApiErrorResponse.from_dict(response.json()) return response_422 + if response.status_code == 500: + response_500 = ApiErrorResponse.from_dict(response.json()) + + return response_500 + + if response.status_code == 503: + response_503 = ApiErrorResponse.from_dict(response.json()) + + return response_503 + if client.raise_on_unexpected_status: raise errors.UnexpectedStatus(response.status_code, response.content) else: @@ -75,7 +115,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[HTTPValidationError | ObligationsPublic]: +) -> Response[ApiErrorResponse | ObligationsPublic]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -90,7 +130,7 @@ def sync_detailed( year: int | None | Unset = UNSET, month: int | None | Unset = UNSET, lifecycle: None | ObligationLifecycle | Unset = UNSET, -) -> Response[HTTPValidationError | ObligationsPublic]: +) -> Response[ApiErrorResponse | ObligationsPublic]: """Read Integration Obligations Args: @@ -103,7 +143,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[HTTPValidationError | ObligationsPublic] + Response[ApiErrorResponse | ObligationsPublic] """ kwargs = _get_kwargs( @@ -125,7 +165,7 @@ def sync( year: int | None | Unset = UNSET, month: int | None | Unset = UNSET, lifecycle: None | ObligationLifecycle | Unset = UNSET, -) -> HTTPValidationError | ObligationsPublic | None: +) -> ApiErrorResponse | ObligationsPublic | None: """Read Integration Obligations Args: @@ -138,7 +178,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - HTTPValidationError | ObligationsPublic + ApiErrorResponse | ObligationsPublic """ return sync_detailed( @@ -155,7 +195,7 @@ async def asyncio_detailed( year: int | None | Unset = UNSET, month: int | None | Unset = UNSET, lifecycle: None | ObligationLifecycle | Unset = UNSET, -) -> Response[HTTPValidationError | ObligationsPublic]: +) -> Response[ApiErrorResponse | ObligationsPublic]: """Read Integration Obligations Args: @@ -168,7 +208,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[HTTPValidationError | ObligationsPublic] + Response[ApiErrorResponse | ObligationsPublic] """ kwargs = _get_kwargs( @@ -188,7 +228,7 @@ async def asyncio( year: int | None | Unset = UNSET, month: int | None | Unset = UNSET, lifecycle: None | ObligationLifecycle | Unset = UNSET, -) -> HTTPValidationError | ObligationsPublic | None: +) -> ApiErrorResponse | ObligationsPublic | None: """Read Integration Obligations Args: @@ -201,7 +241,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - HTTPValidationError | ObligationsPublic + ApiErrorResponse | ObligationsPublic """ return ( diff --git a/src/oblidog_client/generated/api/integration/integration_read_latest_integration_category_data_record.py b/src/oblidog_client/generated/api/integration/integration_read_latest_integration_category_data_record.py index d1fbdbd..0307a3e 100644 --- a/src/oblidog_client/generated/api/integration/integration_read_latest_integration_category_data_record.py +++ b/src/oblidog_client/generated/api/integration/integration_read_latest_integration_category_data_record.py @@ -5,6 +5,7 @@ from ... import errors from ...client import AuthenticatedClient, Client +from ...models.api_error_response import ApiErrorResponse from ...models.category_data_record_public import CategoryDataRecordPublic from ...types import Response @@ -21,12 +22,57 @@ def _get_kwargs() -> dict[str, Any]: def _parse_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> CategoryDataRecordPublic | None: +) -> ApiErrorResponse | CategoryDataRecordPublic | None: if response.status_code == 200: response_200 = CategoryDataRecordPublic.from_dict(response.json()) return response_200 + if response.status_code == 400: + response_400 = ApiErrorResponse.from_dict(response.json()) + + return response_400 + + if response.status_code == 401: + response_401 = ApiErrorResponse.from_dict(response.json()) + + return response_401 + + if response.status_code == 403: + response_403 = ApiErrorResponse.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = ApiErrorResponse.from_dict(response.json()) + + return response_404 + + if response.status_code == 409: + response_409 = ApiErrorResponse.from_dict(response.json()) + + return response_409 + + if response.status_code == 413: + response_413 = ApiErrorResponse.from_dict(response.json()) + + return response_413 + + if response.status_code == 422: + response_422 = ApiErrorResponse.from_dict(response.json()) + + return response_422 + + if response.status_code == 500: + response_500 = ApiErrorResponse.from_dict(response.json()) + + return response_500 + + if response.status_code == 503: + response_503 = ApiErrorResponse.from_dict(response.json()) + + return response_503 + if client.raise_on_unexpected_status: raise errors.UnexpectedStatus(response.status_code, response.content) else: @@ -35,7 +81,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[CategoryDataRecordPublic]: +) -> Response[ApiErrorResponse | CategoryDataRecordPublic]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -47,7 +93,7 @@ def _build_response( def sync_detailed( *, client: AuthenticatedClient, -) -> Response[CategoryDataRecordPublic]: +) -> Response[ApiErrorResponse | CategoryDataRecordPublic]: """Read Latest Integration Category Data Record Raises: @@ -55,7 +101,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[CategoryDataRecordPublic] + Response[ApiErrorResponse | CategoryDataRecordPublic] """ kwargs = _get_kwargs() @@ -70,7 +116,7 @@ def sync_detailed( def sync( *, client: AuthenticatedClient, -) -> CategoryDataRecordPublic | None: +) -> ApiErrorResponse | CategoryDataRecordPublic | None: """Read Latest Integration Category Data Record Raises: @@ -78,7 +124,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - CategoryDataRecordPublic + ApiErrorResponse | CategoryDataRecordPublic """ return sync_detailed( @@ -89,7 +135,7 @@ def sync( async def asyncio_detailed( *, client: AuthenticatedClient, -) -> Response[CategoryDataRecordPublic]: +) -> Response[ApiErrorResponse | CategoryDataRecordPublic]: """Read Latest Integration Category Data Record Raises: @@ -97,7 +143,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[CategoryDataRecordPublic] + Response[ApiErrorResponse | CategoryDataRecordPublic] """ kwargs = _get_kwargs() @@ -110,7 +156,7 @@ async def asyncio_detailed( async def asyncio( *, client: AuthenticatedClient, -) -> CategoryDataRecordPublic | None: +) -> ApiErrorResponse | CategoryDataRecordPublic | None: """Read Latest Integration Category Data Record Raises: @@ -118,7 +164,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - CategoryDataRecordPublic + ApiErrorResponse | CategoryDataRecordPublic """ return ( diff --git a/src/oblidog_client/generated/api/integration/integration_reopen_integration_obligation.py b/src/oblidog_client/generated/api/integration/integration_reopen_integration_obligation.py index e651262..1b7c091 100644 --- a/src/oblidog_client/generated/api/integration/integration_reopen_integration_obligation.py +++ b/src/oblidog_client/generated/api/integration/integration_reopen_integration_obligation.py @@ -6,7 +6,7 @@ from ... import errors from ...client import AuthenticatedClient, Client -from ...models.http_validation_error import HTTPValidationError +from ...models.api_error_response import ApiErrorResponse from ...models.obligation_public import ObligationPublic from ...types import Response @@ -27,17 +27,57 @@ def _get_kwargs( def _parse_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> HTTPValidationError | ObligationPublic | None: +) -> ApiErrorResponse | ObligationPublic | None: if response.status_code == 200: response_200 = ObligationPublic.from_dict(response.json()) return response_200 + if response.status_code == 400: + response_400 = ApiErrorResponse.from_dict(response.json()) + + return response_400 + + if response.status_code == 401: + response_401 = ApiErrorResponse.from_dict(response.json()) + + return response_401 + + if response.status_code == 403: + response_403 = ApiErrorResponse.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = ApiErrorResponse.from_dict(response.json()) + + return response_404 + + if response.status_code == 409: + response_409 = ApiErrorResponse.from_dict(response.json()) + + return response_409 + + if response.status_code == 413: + response_413 = ApiErrorResponse.from_dict(response.json()) + + return response_413 + if response.status_code == 422: - response_422 = HTTPValidationError.from_dict(response.json()) + response_422 = ApiErrorResponse.from_dict(response.json()) return response_422 + if response.status_code == 500: + response_500 = ApiErrorResponse.from_dict(response.json()) + + return response_500 + + if response.status_code == 503: + response_503 = ApiErrorResponse.from_dict(response.json()) + + return response_503 + if client.raise_on_unexpected_status: raise errors.UnexpectedStatus(response.status_code, response.content) else: @@ -46,7 +86,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[HTTPValidationError | ObligationPublic]: +) -> Response[ApiErrorResponse | ObligationPublic]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -59,7 +99,7 @@ def sync_detailed( period: str, *, client: AuthenticatedClient, -) -> Response[HTTPValidationError | ObligationPublic]: +) -> Response[ApiErrorResponse | ObligationPublic]: """Reopen Integration Obligation Args: @@ -71,7 +111,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[HTTPValidationError | ObligationPublic] + Response[ApiErrorResponse | ObligationPublic] """ kwargs = _get_kwargs( @@ -89,7 +129,7 @@ def sync( period: str, *, client: AuthenticatedClient, -) -> HTTPValidationError | ObligationPublic | None: +) -> ApiErrorResponse | ObligationPublic | None: """Reopen Integration Obligation Args: @@ -101,7 +141,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - HTTPValidationError | ObligationPublic + ApiErrorResponse | ObligationPublic """ return sync_detailed( @@ -114,7 +154,7 @@ async def asyncio_detailed( period: str, *, client: AuthenticatedClient, -) -> Response[HTTPValidationError | ObligationPublic]: +) -> Response[ApiErrorResponse | ObligationPublic]: """Reopen Integration Obligation Args: @@ -126,7 +166,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[HTTPValidationError | ObligationPublic] + Response[ApiErrorResponse | ObligationPublic] """ kwargs = _get_kwargs( @@ -142,7 +182,7 @@ async def asyncio( period: str, *, client: AuthenticatedClient, -) -> HTTPValidationError | ObligationPublic | None: +) -> ApiErrorResponse | ObligationPublic | None: """Reopen Integration Obligation Args: @@ -154,7 +194,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - HTTPValidationError | ObligationPublic + ApiErrorResponse | ObligationPublic """ return ( diff --git a/src/oblidog_client/generated/api/integration/integration_start_integration_run.py b/src/oblidog_client/generated/api/integration/integration_start_integration_run.py index 0b4701f..2f81ba0 100644 --- a/src/oblidog_client/generated/api/integration/integration_start_integration_run.py +++ b/src/oblidog_client/generated/api/integration/integration_start_integration_run.py @@ -5,7 +5,7 @@ from ... import errors from ...client import AuthenticatedClient, Client -from ...models.http_validation_error import HTTPValidationError +from ...models.api_error_response import ApiErrorResponse from ...models.integration_conflict_response import IntegrationConflictResponse from ...models.integration_public import IntegrationPublic from ...models.integration_run_start import IntegrationRunStart @@ -33,22 +33,57 @@ def _get_kwargs( def _parse_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> HTTPValidationError | IntegrationConflictResponse | IntegrationPublic | None: +) -> ApiErrorResponse | IntegrationConflictResponse | IntegrationPublic | None: if response.status_code == 200: response_200 = IntegrationPublic.from_dict(response.json()) return response_200 + if response.status_code == 400: + response_400 = ApiErrorResponse.from_dict(response.json()) + + return response_400 + + if response.status_code == 401: + response_401 = ApiErrorResponse.from_dict(response.json()) + + return response_401 + + if response.status_code == 403: + response_403 = ApiErrorResponse.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = ApiErrorResponse.from_dict(response.json()) + + return response_404 + if response.status_code == 409: response_409 = IntegrationConflictResponse.from_dict(response.json()) return response_409 + if response.status_code == 413: + response_413 = ApiErrorResponse.from_dict(response.json()) + + return response_413 + if response.status_code == 422: - response_422 = HTTPValidationError.from_dict(response.json()) + response_422 = ApiErrorResponse.from_dict(response.json()) return response_422 + if response.status_code == 500: + response_500 = ApiErrorResponse.from_dict(response.json()) + + return response_500 + + if response.status_code == 503: + response_503 = ApiErrorResponse.from_dict(response.json()) + + return response_503 + if client.raise_on_unexpected_status: raise errors.UnexpectedStatus(response.status_code, response.content) else: @@ -57,7 +92,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[HTTPValidationError | IntegrationConflictResponse | IntegrationPublic]: +) -> Response[ApiErrorResponse | IntegrationConflictResponse | IntegrationPublic]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -70,7 +105,7 @@ def sync_detailed( *, client: AuthenticatedClient, body: IntegrationRunStart, -) -> Response[HTTPValidationError | IntegrationConflictResponse | IntegrationPublic]: +) -> Response[ApiErrorResponse | IntegrationConflictResponse | IntegrationPublic]: """Start Integration Run Args: @@ -81,7 +116,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[HTTPValidationError | IntegrationConflictResponse | IntegrationPublic] + Response[ApiErrorResponse | IntegrationConflictResponse | IntegrationPublic] """ kwargs = _get_kwargs( @@ -99,7 +134,7 @@ def sync( *, client: AuthenticatedClient, body: IntegrationRunStart, -) -> HTTPValidationError | IntegrationConflictResponse | IntegrationPublic | None: +) -> ApiErrorResponse | IntegrationConflictResponse | IntegrationPublic | None: """Start Integration Run Args: @@ -110,7 +145,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - HTTPValidationError | IntegrationConflictResponse | IntegrationPublic + ApiErrorResponse | IntegrationConflictResponse | IntegrationPublic """ return sync_detailed( @@ -123,7 +158,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient, body: IntegrationRunStart, -) -> Response[HTTPValidationError | IntegrationConflictResponse | IntegrationPublic]: +) -> Response[ApiErrorResponse | IntegrationConflictResponse | IntegrationPublic]: """Start Integration Run Args: @@ -134,7 +169,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[HTTPValidationError | IntegrationConflictResponse | IntegrationPublic] + Response[ApiErrorResponse | IntegrationConflictResponse | IntegrationPublic] """ kwargs = _get_kwargs( @@ -150,7 +185,7 @@ async def asyncio( *, client: AuthenticatedClient, body: IntegrationRunStart, -) -> HTTPValidationError | IntegrationConflictResponse | IntegrationPublic | None: +) -> ApiErrorResponse | IntegrationConflictResponse | IntegrationPublic | None: """Start Integration Run Args: @@ -161,7 +196,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - HTTPValidationError | IntegrationConflictResponse | IntegrationPublic + ApiErrorResponse | IntegrationConflictResponse | IntegrationPublic """ return ( diff --git a/src/oblidog_client/generated/api/integration/integration_update_integration_obligation.py b/src/oblidog_client/generated/api/integration/integration_update_integration_obligation.py index 378e343..6f71406 100644 --- a/src/oblidog_client/generated/api/integration/integration_update_integration_obligation.py +++ b/src/oblidog_client/generated/api/integration/integration_update_integration_obligation.py @@ -6,7 +6,7 @@ from ... import errors from ...client import AuthenticatedClient, Client -from ...models.http_validation_error import HTTPValidationError +from ...models.api_error_response import ApiErrorResponse from ...models.obligation_integration_update import ObligationIntegrationUpdate from ...models.obligation_public import ObligationPublic from ...types import Response @@ -36,17 +36,57 @@ def _get_kwargs( def _parse_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> HTTPValidationError | ObligationPublic | None: +) -> ApiErrorResponse | ObligationPublic | None: if response.status_code == 200: response_200 = ObligationPublic.from_dict(response.json()) return response_200 + if response.status_code == 400: + response_400 = ApiErrorResponse.from_dict(response.json()) + + return response_400 + + if response.status_code == 401: + response_401 = ApiErrorResponse.from_dict(response.json()) + + return response_401 + + if response.status_code == 403: + response_403 = ApiErrorResponse.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = ApiErrorResponse.from_dict(response.json()) + + return response_404 + + if response.status_code == 409: + response_409 = ApiErrorResponse.from_dict(response.json()) + + return response_409 + + if response.status_code == 413: + response_413 = ApiErrorResponse.from_dict(response.json()) + + return response_413 + if response.status_code == 422: - response_422 = HTTPValidationError.from_dict(response.json()) + response_422 = ApiErrorResponse.from_dict(response.json()) return response_422 + if response.status_code == 500: + response_500 = ApiErrorResponse.from_dict(response.json()) + + return response_500 + + if response.status_code == 503: + response_503 = ApiErrorResponse.from_dict(response.json()) + + return response_503 + if client.raise_on_unexpected_status: raise errors.UnexpectedStatus(response.status_code, response.content) else: @@ -55,7 +95,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[HTTPValidationError | ObligationPublic]: +) -> Response[ApiErrorResponse | ObligationPublic]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -69,7 +109,7 @@ def sync_detailed( *, client: AuthenticatedClient, body: ObligationIntegrationUpdate, -) -> Response[HTTPValidationError | ObligationPublic]: +) -> Response[ApiErrorResponse | ObligationPublic]: """Update Integration Obligation Args: @@ -83,7 +123,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[HTTPValidationError | ObligationPublic] + Response[ApiErrorResponse | ObligationPublic] """ kwargs = _get_kwargs( @@ -103,7 +143,7 @@ def sync( *, client: AuthenticatedClient, body: ObligationIntegrationUpdate, -) -> HTTPValidationError | ObligationPublic | None: +) -> ApiErrorResponse | ObligationPublic | None: """Update Integration Obligation Args: @@ -117,7 +157,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - HTTPValidationError | ObligationPublic + ApiErrorResponse | ObligationPublic """ return sync_detailed( @@ -132,7 +172,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient, body: ObligationIntegrationUpdate, -) -> Response[HTTPValidationError | ObligationPublic]: +) -> Response[ApiErrorResponse | ObligationPublic]: """Update Integration Obligation Args: @@ -146,7 +186,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[HTTPValidationError | ObligationPublic] + Response[ApiErrorResponse | ObligationPublic] """ kwargs = _get_kwargs( @@ -164,7 +204,7 @@ async def asyncio( *, client: AuthenticatedClient, body: ObligationIntegrationUpdate, -) -> HTTPValidationError | ObligationPublic | None: +) -> ApiErrorResponse | ObligationPublic | None: """Update Integration Obligation Args: @@ -178,7 +218,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - HTTPValidationError | ObligationPublic + ApiErrorResponse | ObligationPublic """ return ( diff --git a/src/oblidog_client/generated/api/integration/integration_upsert_integration_obligation_component.py b/src/oblidog_client/generated/api/integration/integration_upsert_integration_obligation_component.py index d4ce483..e03805f 100644 --- a/src/oblidog_client/generated/api/integration/integration_upsert_integration_obligation_component.py +++ b/src/oblidog_client/generated/api/integration/integration_upsert_integration_obligation_component.py @@ -6,7 +6,7 @@ from ... import errors from ...client import AuthenticatedClient, Client -from ...models.http_validation_error import HTTPValidationError +from ...models.api_error_response import ApiErrorResponse from ...models.integration_obligation_component_upsert import ( IntegrationObligationComponentUpsert, ) @@ -38,17 +38,57 @@ def _get_kwargs( def _parse_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> HTTPValidationError | ObligationComponentUpsertResult | None: +) -> ApiErrorResponse | ObligationComponentUpsertResult | None: if response.status_code == 200: response_200 = ObligationComponentUpsertResult.from_dict(response.json()) return response_200 + if response.status_code == 400: + response_400 = ApiErrorResponse.from_dict(response.json()) + + return response_400 + + if response.status_code == 401: + response_401 = ApiErrorResponse.from_dict(response.json()) + + return response_401 + + if response.status_code == 403: + response_403 = ApiErrorResponse.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = ApiErrorResponse.from_dict(response.json()) + + return response_404 + + if response.status_code == 409: + response_409 = ApiErrorResponse.from_dict(response.json()) + + return response_409 + + if response.status_code == 413: + response_413 = ApiErrorResponse.from_dict(response.json()) + + return response_413 + if response.status_code == 422: - response_422 = HTTPValidationError.from_dict(response.json()) + response_422 = ApiErrorResponse.from_dict(response.json()) return response_422 + if response.status_code == 500: + response_500 = ApiErrorResponse.from_dict(response.json()) + + return response_500 + + if response.status_code == 503: + response_503 = ApiErrorResponse.from_dict(response.json()) + + return response_503 + if client.raise_on_unexpected_status: raise errors.UnexpectedStatus(response.status_code, response.content) else: @@ -57,7 +97,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[HTTPValidationError | ObligationComponentUpsertResult]: +) -> Response[ApiErrorResponse | ObligationComponentUpsertResult]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -71,7 +111,7 @@ def sync_detailed( *, client: AuthenticatedClient, body: IntegrationObligationComponentUpsert, -) -> Response[HTTPValidationError | ObligationComponentUpsertResult]: +) -> Response[ApiErrorResponse | ObligationComponentUpsertResult]: """Upsert Integration Obligation Component Args: @@ -85,7 +125,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[HTTPValidationError | ObligationComponentUpsertResult] + Response[ApiErrorResponse | ObligationComponentUpsertResult] """ kwargs = _get_kwargs( @@ -105,7 +145,7 @@ def sync( *, client: AuthenticatedClient, body: IntegrationObligationComponentUpsert, -) -> HTTPValidationError | ObligationComponentUpsertResult | None: +) -> ApiErrorResponse | ObligationComponentUpsertResult | None: """Upsert Integration Obligation Component Args: @@ -119,7 +159,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - HTTPValidationError | ObligationComponentUpsertResult + ApiErrorResponse | ObligationComponentUpsertResult """ return sync_detailed( @@ -134,7 +174,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient, body: IntegrationObligationComponentUpsert, -) -> Response[HTTPValidationError | ObligationComponentUpsertResult]: +) -> Response[ApiErrorResponse | ObligationComponentUpsertResult]: """Upsert Integration Obligation Component Args: @@ -148,7 +188,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[HTTPValidationError | ObligationComponentUpsertResult] + Response[ApiErrorResponse | ObligationComponentUpsertResult] """ kwargs = _get_kwargs( @@ -166,7 +206,7 @@ async def asyncio( *, client: AuthenticatedClient, body: IntegrationObligationComponentUpsert, -) -> HTTPValidationError | ObligationComponentUpsertResult | None: +) -> ApiErrorResponse | ObligationComponentUpsertResult | None: """Upsert Integration Obligation Component Args: @@ -180,7 +220,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - HTTPValidationError | ObligationComponentUpsertResult + ApiErrorResponse | ObligationComponentUpsertResult """ return ( diff --git a/src/oblidog_client/generated/models/__init__.py b/src/oblidog_client/generated/models/__init__.py index fe8d17d..7cbf0ce 100644 --- a/src/oblidog_client/generated/models/__init__.py +++ b/src/oblidog_client/generated/models/__init__.py @@ -1,15 +1,16 @@ """Contains all the data models used in inputs/outputs""" +from .api_error_response import ApiErrorResponse +from .api_error_response_code import ApiErrorResponseCode +from .api_error_response_params import ApiErrorResponseParams from .category_data_record_public import CategoryDataRecordPublic from .category_data_record_public_data import CategoryDataRecordPublicData from .category_data_records_public import CategoryDataRecordsPublic from .category_data_schema_public import CategoryDataSchemaPublic from .category_data_schema_public_schema import CategoryDataSchemaPublicSchema -from .context import Context from .counterparty_summary_public import CounterpartySummaryPublic from .current_value_source import CurrentValueSource from .effective_value_source_mode import EffectiveValueSourceMode -from .http_validation_error import HTTPValidationError from .integration_category_data_record_create import IntegrationCategoryDataRecordCreate from .integration_category_data_record_create_data import ( IntegrationCategoryDataRecordCreateData, @@ -17,6 +18,8 @@ from .integration_conflict_code import IntegrationConflictCode from .integration_conflict_detail import IntegrationConflictDetail from .integration_conflict_response import IntegrationConflictResponse +from .integration_conflict_response_code import IntegrationConflictResponseCode +from .integration_conflict_response_params import IntegrationConflictResponseParams from .integration_context_category_public import IntegrationContextCategoryPublic from .integration_context_integration_public import IntegrationContextIntegrationPublic from .integration_context_public import IntegrationContextPublic @@ -47,25 +50,27 @@ from .obligation_period_public import ObligationPeriodPublic from .obligation_public import ObligationPublic from .obligations_public import ObligationsPublic -from .validation_error import ValidationError from .value_state import ValueState __all__ = ( + "ApiErrorResponse", + "ApiErrorResponseCode", + "ApiErrorResponseParams", "CategoryDataRecordPublic", "CategoryDataRecordPublicData", "CategoryDataRecordsPublic", "CategoryDataSchemaPublic", "CategoryDataSchemaPublicSchema", - "Context", "CounterpartySummaryPublic", "CurrentValueSource", "EffectiveValueSourceMode", - "HTTPValidationError", "IntegrationCategoryDataRecordCreate", "IntegrationCategoryDataRecordCreateData", "IntegrationConflictCode", "IntegrationConflictDetail", "IntegrationConflictResponse", + "IntegrationConflictResponseCode", + "IntegrationConflictResponseParams", "IntegrationContextCategoryPublic", "IntegrationContextIntegrationPublic", "IntegrationContextPublic", @@ -90,6 +95,5 @@ "ObligationPeriodPublic", "ObligationPublic", "ObligationsPublic", - "ValidationError", "ValueState", ) diff --git a/src/oblidog_client/generated/models/api_error_response.py b/src/oblidog_client/generated/models/api_error_response.py new file mode 100644 index 0000000..00b274a --- /dev/null +++ b/src/oblidog_client/generated/models/api_error_response.py @@ -0,0 +1,94 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, Self, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..models.api_error_response_code import ApiErrorResponseCode +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.api_error_response_params import ApiErrorResponseParams + + +T = TypeVar("T", bound="ApiErrorResponse") + + +@_attrs_define +class ApiErrorResponse: + """ + Attributes: + code (ApiErrorResponseCode): + detail (Any): + params (ApiErrorResponseParams | Unset): + """ + + code: ApiErrorResponseCode + detail: Any + params: ApiErrorResponseParams | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + code = self.code.value + + detail = self.detail + + params: dict[str, Any] | Unset = UNSET + if not isinstance(self.params, Unset): + params = self.params.to_dict() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "code": code, + "detail": detail, + } + ) + if params is not UNSET: + field_dict["params"] = params + + return field_dict + + @classmethod + def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: + from ..models.api_error_response_params import ApiErrorResponseParams + + d = dict(src_dict) + code = ApiErrorResponseCode(d.pop("code")) + + detail = d.pop("detail") + + _params = d.pop("params", UNSET) + params: ApiErrorResponseParams | Unset + if isinstance(_params, Unset): + params = UNSET + else: + params = ApiErrorResponseParams.from_dict(_params) + + api_error_response = cls( + code=code, + detail=detail, + params=params, + ) + + api_error_response.additional_properties = d + return api_error_response + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/oblidog_client/generated/models/api_error_response_code.py b/src/oblidog_client/generated/models/api_error_response_code.py new file mode 100644 index 0000000..62a7ac0 --- /dev/null +++ b/src/oblidog_client/generated/models/api_error_response_code.py @@ -0,0 +1,93 @@ +from enum import Enum + + +class ApiErrorResponseCode(str, Enum): + ANALYTICS_INVALID_RANGE = "analytics_invalid_range" + AUTH_CSRF_INVALID = "auth_csrf_invalid" + AUTH_INACTIVE_API_KEY = "auth_inactive_api_key" + AUTH_INVALID_API_KEY = "auth_invalid_api_key" + AUTH_INVALID_CREDENTIALS = "auth_invalid_credentials" + AUTH_INVALID_TOKEN = "auth_invalid_token" + AUTH_ORIGIN_FORBIDDEN = "auth_origin_forbidden" + AUTH_REQUIRED = "auth_required" + AUTH_SESSION_EXPIRED = "auth_session_expired" + CAPABILITY_DISABLED = "capability_disabled" + CATEGORY_CODE_CONFLICT = "category_code_conflict" + CATEGORY_CODE_INVALID = "category_code_invalid" + CATEGORY_CONFLICT = "category_conflict" + CATEGORY_CROSS_LEDGER = "category_cross_ledger" + CATEGORY_CSV_UNSUPPORTED = "category_csv_unsupported" + CATEGORY_DATA_INVALID = "category_data_invalid" + CATEGORY_DATA_NOT_FOUND = "category_data_not_found" + CATEGORY_GROUP_ARCHIVED = "category_group_archived" + CATEGORY_GROUP_CONFLICT = "category_group_conflict" + CATEGORY_GROUP_INVALID_VALUES = "category_group_invalid_values" + CATEGORY_GROUP_IN_USE = "category_group_in_use" + CATEGORY_GROUP_NOT_FOUND = "category_group_not_found" + CATEGORY_INVALID_VALUES = "category_invalid_values" + CATEGORY_NOT_FOUND = "category_not_found" + CATEGORY_SCHEMA_INCOMPATIBLE = "category_schema_incompatible" + CATEGORY_SCHEMA_INVALID = "category_schema_invalid" + CATEGORY_SCHEMA_NOT_CONFIGURED = "category_schema_not_configured" + CATEGORY_SCHEMA_NOT_FOUND = "category_schema_not_found" + COUNTERPARTY_CONFLICT = "counterparty_conflict" + COUNTERPARTY_INVALID_VALUES = "counterparty_invalid_values" + COUNTERPARTY_IN_USE = "counterparty_in_use" + COUNTERPARTY_NOT_FOUND = "counterparty_not_found" + COUNTERPARTY_PREVIEW_STALE = "counterparty_preview_stale" + COUNTERPARTY_REQUIRED = "counterparty_required" + DEMO_LIMIT_REACHED = "demo_limit_reached" + DEMO_READ_ONLY = "demo_read_only" + DEMO_REQUEST_TOO_LARGE = "demo_request_too_large" + DEMO_RESET_FAILED = "demo_reset_failed" + DEMO_RESET_RUNNING = "demo_reset_running" + INTEGRATION_CONFLICT = "integration_conflict" + INTEGRATION_INVALID_LIMITS = "integration_invalid_limits" + INTEGRATION_KEY_NOT_FOUND = "integration_key_not_found" + INTEGRATION_NOT_FOUND = "integration_not_found" + INTERNAL_ERROR = "internal_error" + INVITATION_ACCEPTED = "invitation_accepted" + INVITATION_CONFLICT = "invitation_conflict" + INVITATION_EXPIRED = "invitation_expired" + INVITATION_NOT_FOUND = "invitation_not_found" + INVITATION_REVOKED = "invitation_revoked" + LEDGER_CATEGORIES_IN_USE = "ledger_categories_in_use" + LEDGER_INVALID_VALUES = "ledger_invalid_values" + LEDGER_MEMBERSHIP_CONFLICT = "ledger_membership_conflict" + LEDGER_MEMBER_NOT_FOUND = "ledger_member_not_found" + LEDGER_NOT_FOUND = "ledger_not_found" + LEDGER_OWNER_CHANGE_FORBIDDEN = "ledger_owner_change_forbidden" + LEDGER_OWNER_REMOVE_FORBIDDEN = "ledger_owner_remove_forbidden" + LEGACY_IMPORT_DISABLED = "legacy_import_disabled" + LEGACY_IMPORT_NOT_FOUND = "legacy_import_not_found" + LEGACY_IMPORT_RUNNING = "legacy_import_running" + OBLIGATION_COMPONENT_CONFLICT = "obligation_component_conflict" + OBLIGATION_COMPONENT_NOT_FOUND = "obligation_component_not_found" + OBLIGATION_CONFLICT = "obligation_conflict" + OBLIGATION_INVALID_KEY = "obligation_invalid_key" + OBLIGATION_INVALID_LIFECYCLE = "obligation_invalid_lifecycle" + OBLIGATION_INVALID_PERIOD = "obligation_invalid_period" + OBLIGATION_INVALID_VALUES = "obligation_invalid_values" + OBLIGATION_MANUAL_FORBIDDEN = "obligation_manual_forbidden" + OBLIGATION_NOT_FOUND = "obligation_not_found" + OBLIGATION_NOT_READY = "obligation_not_ready" + OBLIGATION_READ_ONLY = "obligation_read_only" + PERMISSION_DENIED = "permission_denied" + REQUEST_INVALID = "request_invalid" + REQUEST_VALIDATION_FAILED = "request_validation_failed" + RESOURCE_NOT_FOUND = "resource_not_found" + SERVICE_UNAVAILABLE = "service_unavailable" + SYSTEM_RUN_DISABLED_TASKS = "system_run_disabled_tasks" + SYSTEM_RUN_NON_MANUAL_TASKS = "system_run_non_manual_tasks" + SYSTEM_RUN_NOT_FOUND = "system_run_not_found" + SYSTEM_RUN_RUNNING = "system_run_running" + SYSTEM_RUN_UNKNOWN_TASKS = "system_run_unknown_tasks" + USER_EMAIL_CONFLICT = "user_email_conflict" + USER_INACTIVE = "user_inactive" + USER_INCORRECT_PASSWORD = "user_incorrect_password" + USER_NOT_FOUND = "user_not_found" + USER_SAME_PASSWORD = "user_same_password" + USER_SELF_DELETE_FORBIDDEN = "user_self_delete_forbidden" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/oblidog_client/generated/models/context.py b/src/oblidog_client/generated/models/api_error_response_params.py similarity index 82% rename from src/oblidog_client/generated/models/context.py rename to src/oblidog_client/generated/models/api_error_response_params.py index d37dd44..4f4e460 100644 --- a/src/oblidog_client/generated/models/context.py +++ b/src/oblidog_client/generated/models/api_error_response_params.py @@ -6,11 +6,11 @@ from attrs import define as _attrs_define from attrs import field as _attrs_field -T = TypeVar("T", bound="Context") +T = TypeVar("T", bound="ApiErrorResponseParams") @_attrs_define -class Context: +class ApiErrorResponseParams: """ """ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) @@ -25,10 +25,10 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: d = dict(src_dict) - context = cls() + api_error_response_params = cls() - context.additional_properties = d - return context + api_error_response_params.additional_properties = d + return api_error_response_params @property def additional_keys(self) -> list[str]: diff --git a/src/oblidog_client/generated/models/http_validation_error.py b/src/oblidog_client/generated/models/http_validation_error.py deleted file mode 100644 index 69fd68a..0000000 --- a/src/oblidog_client/generated/models/http_validation_error.py +++ /dev/null @@ -1,79 +0,0 @@ -from __future__ import annotations - -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, Self, TypeVar - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.validation_error import ValidationError - - -T = TypeVar("T", bound="HTTPValidationError") - - -@_attrs_define -class HTTPValidationError: - """ - Attributes: - detail (list[ValidationError] | Unset): - """ - - detail: list[ValidationError] | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - detail: list[dict[str, Any]] | Unset = UNSET - if not isinstance(self.detail, Unset): - detail = [] - for detail_item_data in self.detail: - detail_item = detail_item_data.to_dict() - detail.append(detail_item) - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update({}) - if detail is not UNSET: - field_dict["detail"] = detail - - return field_dict - - @classmethod - def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: - from ..models.validation_error import ValidationError - - d = dict(src_dict) - _detail = d.pop("detail", UNSET) - detail: list[ValidationError] | Unset = UNSET - if _detail is not UNSET: - detail = [] - for detail_item_data in _detail: - detail_item = ValidationError.from_dict(detail_item_data) - - detail.append(detail_item) - - http_validation_error = cls( - detail=detail, - ) - - http_validation_error.additional_properties = d - return http_validation_error - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/src/oblidog_client/generated/models/integration_conflict_response.py b/src/oblidog_client/generated/models/integration_conflict_response.py index 65a0de3..3ef0655 100644 --- a/src/oblidog_client/generated/models/integration_conflict_response.py +++ b/src/oblidog_client/generated/models/integration_conflict_response.py @@ -6,8 +6,14 @@ from attrs import define as _attrs_define from attrs import field as _attrs_field +from ..models.integration_conflict_response_code import IntegrationConflictResponseCode +from ..types import UNSET, Unset + if TYPE_CHECKING: from ..models.integration_conflict_detail import IntegrationConflictDetail + from ..models.integration_conflict_response_params import ( + IntegrationConflictResponseParams, + ) T = TypeVar("T", bound="IntegrationConflictResponse") @@ -17,34 +23,61 @@ class IntegrationConflictResponse: """ Attributes: + code (IntegrationConflictResponseCode): detail (IntegrationConflictDetail): + params (IntegrationConflictResponseParams | Unset): """ + code: IntegrationConflictResponseCode detail: IntegrationConflictDetail + params: IntegrationConflictResponseParams | Unset = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: + code = self.code.value + detail = self.detail.to_dict() + params: dict[str, Any] | Unset = UNSET + if not isinstance(self.params, Unset): + params = self.params.to_dict() + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { + "code": code, "detail": detail, } ) + if params is not UNSET: + field_dict["params"] = params return field_dict @classmethod def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: from ..models.integration_conflict_detail import IntegrationConflictDetail + from ..models.integration_conflict_response_params import ( + IntegrationConflictResponseParams, + ) d = dict(src_dict) + code = IntegrationConflictResponseCode(d.pop("code")) + detail = IntegrationConflictDetail.from_dict(d.pop("detail")) + _params = d.pop("params", UNSET) + params: IntegrationConflictResponseParams | Unset + if isinstance(_params, Unset): + params = UNSET + else: + params = IntegrationConflictResponseParams.from_dict(_params) + integration_conflict_response = cls( + code=code, detail=detail, + params=params, ) integration_conflict_response.additional_properties = d diff --git a/src/oblidog_client/generated/models/integration_conflict_response_code.py b/src/oblidog_client/generated/models/integration_conflict_response_code.py new file mode 100644 index 0000000..c118d9c --- /dev/null +++ b/src/oblidog_client/generated/models/integration_conflict_response_code.py @@ -0,0 +1,93 @@ +from enum import Enum + + +class IntegrationConflictResponseCode(str, Enum): + ANALYTICS_INVALID_RANGE = "analytics_invalid_range" + AUTH_CSRF_INVALID = "auth_csrf_invalid" + AUTH_INACTIVE_API_KEY = "auth_inactive_api_key" + AUTH_INVALID_API_KEY = "auth_invalid_api_key" + AUTH_INVALID_CREDENTIALS = "auth_invalid_credentials" + AUTH_INVALID_TOKEN = "auth_invalid_token" + AUTH_ORIGIN_FORBIDDEN = "auth_origin_forbidden" + AUTH_REQUIRED = "auth_required" + AUTH_SESSION_EXPIRED = "auth_session_expired" + CAPABILITY_DISABLED = "capability_disabled" + CATEGORY_CODE_CONFLICT = "category_code_conflict" + CATEGORY_CODE_INVALID = "category_code_invalid" + CATEGORY_CONFLICT = "category_conflict" + CATEGORY_CROSS_LEDGER = "category_cross_ledger" + CATEGORY_CSV_UNSUPPORTED = "category_csv_unsupported" + CATEGORY_DATA_INVALID = "category_data_invalid" + CATEGORY_DATA_NOT_FOUND = "category_data_not_found" + CATEGORY_GROUP_ARCHIVED = "category_group_archived" + CATEGORY_GROUP_CONFLICT = "category_group_conflict" + CATEGORY_GROUP_INVALID_VALUES = "category_group_invalid_values" + CATEGORY_GROUP_IN_USE = "category_group_in_use" + CATEGORY_GROUP_NOT_FOUND = "category_group_not_found" + CATEGORY_INVALID_VALUES = "category_invalid_values" + CATEGORY_NOT_FOUND = "category_not_found" + CATEGORY_SCHEMA_INCOMPATIBLE = "category_schema_incompatible" + CATEGORY_SCHEMA_INVALID = "category_schema_invalid" + CATEGORY_SCHEMA_NOT_CONFIGURED = "category_schema_not_configured" + CATEGORY_SCHEMA_NOT_FOUND = "category_schema_not_found" + COUNTERPARTY_CONFLICT = "counterparty_conflict" + COUNTERPARTY_INVALID_VALUES = "counterparty_invalid_values" + COUNTERPARTY_IN_USE = "counterparty_in_use" + COUNTERPARTY_NOT_FOUND = "counterparty_not_found" + COUNTERPARTY_PREVIEW_STALE = "counterparty_preview_stale" + COUNTERPARTY_REQUIRED = "counterparty_required" + DEMO_LIMIT_REACHED = "demo_limit_reached" + DEMO_READ_ONLY = "demo_read_only" + DEMO_REQUEST_TOO_LARGE = "demo_request_too_large" + DEMO_RESET_FAILED = "demo_reset_failed" + DEMO_RESET_RUNNING = "demo_reset_running" + INTEGRATION_CONFLICT = "integration_conflict" + INTEGRATION_INVALID_LIMITS = "integration_invalid_limits" + INTEGRATION_KEY_NOT_FOUND = "integration_key_not_found" + INTEGRATION_NOT_FOUND = "integration_not_found" + INTERNAL_ERROR = "internal_error" + INVITATION_ACCEPTED = "invitation_accepted" + INVITATION_CONFLICT = "invitation_conflict" + INVITATION_EXPIRED = "invitation_expired" + INVITATION_NOT_FOUND = "invitation_not_found" + INVITATION_REVOKED = "invitation_revoked" + LEDGER_CATEGORIES_IN_USE = "ledger_categories_in_use" + LEDGER_INVALID_VALUES = "ledger_invalid_values" + LEDGER_MEMBERSHIP_CONFLICT = "ledger_membership_conflict" + LEDGER_MEMBER_NOT_FOUND = "ledger_member_not_found" + LEDGER_NOT_FOUND = "ledger_not_found" + LEDGER_OWNER_CHANGE_FORBIDDEN = "ledger_owner_change_forbidden" + LEDGER_OWNER_REMOVE_FORBIDDEN = "ledger_owner_remove_forbidden" + LEGACY_IMPORT_DISABLED = "legacy_import_disabled" + LEGACY_IMPORT_NOT_FOUND = "legacy_import_not_found" + LEGACY_IMPORT_RUNNING = "legacy_import_running" + OBLIGATION_COMPONENT_CONFLICT = "obligation_component_conflict" + OBLIGATION_COMPONENT_NOT_FOUND = "obligation_component_not_found" + OBLIGATION_CONFLICT = "obligation_conflict" + OBLIGATION_INVALID_KEY = "obligation_invalid_key" + OBLIGATION_INVALID_LIFECYCLE = "obligation_invalid_lifecycle" + OBLIGATION_INVALID_PERIOD = "obligation_invalid_period" + OBLIGATION_INVALID_VALUES = "obligation_invalid_values" + OBLIGATION_MANUAL_FORBIDDEN = "obligation_manual_forbidden" + OBLIGATION_NOT_FOUND = "obligation_not_found" + OBLIGATION_NOT_READY = "obligation_not_ready" + OBLIGATION_READ_ONLY = "obligation_read_only" + PERMISSION_DENIED = "permission_denied" + REQUEST_INVALID = "request_invalid" + REQUEST_VALIDATION_FAILED = "request_validation_failed" + RESOURCE_NOT_FOUND = "resource_not_found" + SERVICE_UNAVAILABLE = "service_unavailable" + SYSTEM_RUN_DISABLED_TASKS = "system_run_disabled_tasks" + SYSTEM_RUN_NON_MANUAL_TASKS = "system_run_non_manual_tasks" + SYSTEM_RUN_NOT_FOUND = "system_run_not_found" + SYSTEM_RUN_RUNNING = "system_run_running" + SYSTEM_RUN_UNKNOWN_TASKS = "system_run_unknown_tasks" + USER_EMAIL_CONFLICT = "user_email_conflict" + USER_INACTIVE = "user_inactive" + USER_INCORRECT_PASSWORD = "user_incorrect_password" + USER_NOT_FOUND = "user_not_found" + USER_SAME_PASSWORD = "user_same_password" + USER_SELF_DELETE_FORBIDDEN = "user_self_delete_forbidden" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/oblidog_client/generated/models/integration_conflict_response_params.py b/src/oblidog_client/generated/models/integration_conflict_response_params.py new file mode 100644 index 0000000..9968f34 --- /dev/null +++ b/src/oblidog_client/generated/models/integration_conflict_response_params.py @@ -0,0 +1,47 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, Self, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="IntegrationConflictResponseParams") + + +@_attrs_define +class IntegrationConflictResponseParams: + """ """ + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: + d = dict(src_dict) + integration_conflict_response_params = cls() + + integration_conflict_response_params.additional_properties = d + return integration_conflict_response_params + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/oblidog_client/generated/models/validation_error.py b/src/oblidog_client/generated/models/validation_error.py deleted file mode 100644 index fb42629..0000000 --- a/src/oblidog_client/generated/models/validation_error.py +++ /dev/null @@ -1,123 +0,0 @@ -from __future__ import annotations - -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, Self, TypeVar, cast - -from attrs import define as _attrs_define -from attrs import field as _attrs_field - -from ..types import UNSET, Unset - -if TYPE_CHECKING: - from ..models.context import Context - - -T = TypeVar("T", bound="ValidationError") - - -@_attrs_define -class ValidationError: - """ - Attributes: - loc (list[int | str]): - msg (str): - type_ (str): - ctx (Context | Unset): - input_ (Any | Unset): - """ - - loc: list[int | str] - msg: str - type_: str - ctx: Context | Unset = UNSET - input_: Any | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - - def to_dict(self) -> dict[str, Any]: - loc = [] - for loc_item_data in self.loc: - loc_item: int | str - loc_item = loc_item_data - loc.append(loc_item) - - msg = self.msg - - type_ = self.type_ - - ctx: dict[str, Any] | Unset = UNSET - if not isinstance(self.ctx, Unset): - ctx = self.ctx.to_dict() - - input_ = self.input_ - - field_dict: dict[str, Any] = {} - field_dict.update(self.additional_properties) - field_dict.update( - { - "loc": loc, - "msg": msg, - "type": type_, - } - ) - if ctx is not UNSET: - field_dict["ctx"] = ctx - if input_ is not UNSET: - field_dict["input"] = input_ - - return field_dict - - @classmethod - def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: - from ..models.context import Context - - d = dict(src_dict) - loc = [] - _loc = d.pop("loc") - for loc_item_data in _loc: - - def _parse_loc_item(data: object) -> int | str: - return cast(int | str, data) - - loc_item = _parse_loc_item(loc_item_data) - - loc.append(loc_item) - - msg = d.pop("msg") - - type_ = d.pop("type") - - _ctx = d.pop("ctx", UNSET) - ctx: Context | Unset - if isinstance(_ctx, Unset): - ctx = UNSET - else: - ctx = Context.from_dict(_ctx) - - input_ = d.pop("input", UNSET) - - validation_error = cls( - loc=loc, - msg=msg, - type_=type_, - ctx=ctx, - input_=input_, - ) - - validation_error.additional_properties = d - return validation_error - - @property - def additional_keys(self) -> list[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/tests/test_client.py b/tests/test_client.py index 5f893a7..03010a6 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -13,7 +13,6 @@ ObligationLifecycle, ObligationPeriod, ) -from oblidog_client.generated import errors OBLIGATION = { "id": "11111111-1111-1111-1111-111111111111", @@ -191,13 +190,14 @@ def handler(request: httpx.Request) -> httpx.Response: return httpx.Response( 422, json={ + "code": "request_validation_failed", "detail": [ { "loc": ["query", "month"], "msg": "Input should be less than or equal to 12", "type": "less_than_equal", } - ] + ], }, ) @@ -211,15 +211,65 @@ def handler(request: httpx.Request) -> httpx.Response: def test_undocumented_status_is_not_silently_returned_as_none() -> None: def handler(request: httpx.Request) -> httpx.Response: assert_auth(request) - return httpx.Response(500, text="boom") + return httpx.Response(418, text="boom") with ( make_client(httpx.MockTransport(handler)) as client, - pytest.raises(errors.UnexpectedStatus) as exc_info, + pytest.raises(OblidogApiError) as exc_info, ): client.obligations.get(PERIOD) - assert exc_info.value.status_code == 500 + assert exc_info.value.status_code == 418 + assert exc_info.value.content == b"boom" + assert exc_info.value.__cause__ is not None + + +@pytest.mark.parametrize( + ("status", "code"), + [ + (400, "request_invalid"), + (401, "auth_invalid_api_key"), + (403, "permission_denied"), + (404, "resource_not_found"), + (409, "obligation_conflict"), + (413, "demo_request_too_large"), + (422, "request_validation_failed"), + (500, "internal_error"), + (503, "service_unavailable"), + ], +) +@pytest.mark.parametrize("operation", ["list", "mark_paid", "latest", "context"]) +def test_documented_errors_preserve_status_and_body( + status: int, code: str, operation: str +) -> None: + calls = 0 + payload = { + "code": code, + "detail": "Request rejected", + "params": {"field": "amount"}, + } + response = httpx.Response(status, json=payload) + + def handler(request: httpx.Request) -> httpx.Response: + nonlocal calls + calls += 1 + assert_auth(request) + return response + + expected = OblidogValidationError if status == 422 else OblidogApiError + with make_client(httpx.MockTransport(handler)) as client: + with pytest.raises(expected) as exc: + if operation == "list": + client.obligations.list() + elif operation == "mark_paid": + client.obligations.mark_paid(PERIOD) + elif operation == "latest": + client.category_data.latest() + else: + client.integrations.context() + assert exc.value.status_code == status + assert exc.value.content == response.content + assert calls == 1 def test_category_data_schema_and_list_send_expected_requests() -> None: @@ -281,11 +331,13 @@ def handler(request: httpx.Request) -> httpx.Response: def test_category_data_latest_validation_becomes_high_level_exception() -> None: def handler(request: httpx.Request) -> httpx.Response: - return httpx.Response(422, json={"detail": []}) + return httpx.Response( + 422, json={"code": "request_validation_failed", "detail": []} + ) with ( make_client(httpx.MockTransport(handler)) as client, - pytest.raises(errors.UnexpectedStatus), + pytest.raises(OblidogValidationError), ): client.category_data.latest() @@ -327,14 +379,14 @@ def handler(request: httpx.Request) -> httpx.Response: def test_missing_parsed_response_becomes_api_error() -> None: def handler(request: httpx.Request) -> httpx.Response: - return httpx.Response(500, text="boom") + return httpx.Response(204) with make_client(httpx.MockTransport(handler)) as client: client._client.raise_on_unexpected_status = False with pytest.raises(OblidogApiError) as exc_info: client.category_data.latest() - assert exc_info.value.status_code == 0 + assert exc_info.value.status_code == 204 INTEGRATION = { @@ -600,10 +652,16 @@ def handler(request: httpx.Request) -> httpx.Response: nonlocal calls calls += 1 assert_auth(request) - return httpx.Response(status, json={"detail": {"code": "revision_conflict"}}) + return httpx.Response( + status, + json={ + "code": "integration_conflict", + "detail": {"code": "revision_conflict"}, + }, + ) with make_client(httpx.MockTransport(handler)) as client: - with pytest.raises(errors.UnexpectedStatus) as exc: + with pytest.raises(OblidogApiError) as exc: client.integrations.start(run_id=uuid.uuid4(), expected_revision=0) assert exc.value.status_code == status assert calls == 1 @@ -617,9 +675,10 @@ def handler(request: httpx.Request) -> httpx.Response: return httpx.Response( 422, json={ + "code": "request_validation_failed", "detail": [ {"loc": ["body", "run_id"], "msg": "invalid", "type": "value_error"} - ] + ], }, ) @@ -659,7 +718,14 @@ def handler(request: httpx.Request) -> httpx.Response: calls += 1 assert_auth(request) assert request.url.path.endswith("/" + operation) - return httpx.Response(409, json={"detail": {"code": code}}) + return httpx.Response( + 409, + json={ + "code": "integration_conflict", + "detail": {"code": code}, + "params": {"revision": 7}, + }, + ) with make_client(httpx.MockTransport(handler)) as client: with pytest.raises(OblidogConflictError) as exc: @@ -674,7 +740,11 @@ def handler(request: httpx.Request) -> httpx.Response: assert isinstance(exc.value, OblidogApiError) assert exc.value.status_code == 409 assert exc.value.code is IntegrationConflictCode(code) - assert json.loads(exc.value.content) == {"detail": {"code": code}} + assert json.loads(exc.value.content) == { + "code": "integration_conflict", + "detail": {"code": code}, + "params": {"revision": 7}, + } assert calls == 1 @@ -694,7 +764,13 @@ def test_low_level_client_parses_documented_conflict() -> None: def handler(request: httpx.Request) -> httpx.Response: assert_auth(request) - return httpx.Response(409, json={"detail": {"code": "revision_conflict"}}) + return httpx.Response( + 409, + json={ + "code": "integration_conflict", + "detail": {"code": "revision_conflict"}, + }, + ) with make_client(httpx.MockTransport(handler)) as client: response = integration_start_integration_run.sync_detailed(