Skip to content

Commit ac0e49b

Browse files
committed
deploy working
1 parent bb623f6 commit ac0e49b

File tree

9 files changed

+72
-23
lines changed

9 files changed

+72
-23
lines changed

examples/01_simple_example.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import logging
2+
import tadata_sdk
3+
4+
import os
5+
6+
# Configure logging to display SDK logs
7+
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")
8+
9+
tadata_sdk.deploy(
10+
api_key=os.getenv("TADATA_API_KEY", ""),
11+
openapi_spec_path="examples/petstore_openapi.json",
12+
base_url="https://petstore3.swagger.io/api/v3",
13+
)
File renamed without changes.

instuctions.txt

Whitespace-only changes.

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ dev = [
3737
"pytest-cov>=6.1.1",
3838
"pre-commit>=4.2.0",
3939
"types-pyyaml>=6.0.12.20250516",
40+
"pip>=25.1.1",
4041
]
4142

4243
[project.urls]
@@ -48,7 +49,7 @@ Documentation = "https://github.com/tadata-org/tadata-python-sdk#readme"
4849
"Changelog" = "https://github.com/tadata-org/tadata-python-sdk/blob/main/CHANGELOG.md"
4950

5051
[tool.hatch.build.targets.wheel]
51-
packages = ["tadata_python_sdk"]
52+
packages = ["tadata_sdk"]
5253

5354
[tool.ruff]
5455
line-length = 120

tadata_sdk/core/sdk.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ def __init__(self, response: DeploymentResponse) -> None:
3636
self.updated = data.updated
3737
self.created_at = data.deployment.created_at or datetime.now()
3838

39+
def __str__(self) -> str:
40+
"""Return a string representation of the deployment result."""
41+
return f"DeploymentResult(id={self.id}, updated={self.updated}, created_at={self.created_at})"
42+
3943

4044
@overload
4145
def deploy(
@@ -171,23 +175,28 @@ def deploy(
171175
if auth_config is not None:
172176
mcp_auth_config = AuthConfig.model_validate(auth_config.model_dump())
173177

174-
# Create API client
175178
client = ApiClient(
176179
api_key=api_key,
177180
version=api_version,
178181
timeout=timeout,
179182
)
180183

181-
# Create deployment request
182184
request = UpsertDeploymentRequest(
183-
open_api_spec=spec,
185+
openApiSpec=spec,
184186
name=name,
185-
base_url=base_url,
186-
auth_config=mcp_auth_config,
187+
baseUrl=base_url,
188+
authConfig=mcp_auth_config,
187189
)
188190

189-
# Make API request to deploy
190191
api_response: DeploymentResponse = client.deploy_from_openapi(request)
191192

192-
# Process response
193-
return DeploymentResult(api_response)
193+
result = DeploymentResult(api_response)
194+
195+
logger.info(f"Deployment successful - ID: {result.id}")
196+
197+
if result.updated:
198+
logger.info("New deployment was created")
199+
else:
200+
logger.info("No changes in spec, deployment was skipped")
201+
202+
return result

tadata_sdk/http/client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def _handle_response_error(self, response: httpx.Response) -> None:
7777
logger.error(f"Authentication error: {status_code}")
7878
raise AuthError(error_msg, cause=Exception(str(error_data)))
7979

80-
logger.error(f"API error: {status_code} - {error_msg}")
80+
logger.error(f"API error: {status_code} - {error_msg}\n{error_data}")
8181
raise ApiError(error_msg, status_code, error_data)
8282

8383
def _request(
@@ -150,7 +150,9 @@ def deploy_from_openapi(self, request: UpsertDeploymentRequest) -> DeploymentRes
150150
"""
151151
logger.info("Deploying MCP server from OpenAPI spec")
152152

153-
response = self._request("POST", "/api/deployments/from-openapi", data=request.model_dump(by_alias=True))
153+
response = self._request(
154+
"POST", "/api/deployments/from-openapi", data=request.model_dump(by_alias=True, exclude_none=True)
155+
)
154156

155157
try:
156158
result = DeploymentResponse.model_validate(response.json())

tadata_sdk/http/schemas.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,44 +62,53 @@ class AuthConfig(BaseModel):
6262
"x-apikey",
6363
],
6464
description="Headers to pass through from MCP clients to the upstream API",
65+
alias="passHeaders",
6566
)
6667
pass_query_params: List[str] = Field(
6768
default=["api-key", "api_key", "apikey"],
6869
description="Query parameters to pass through from MCP clients to the upstream API",
70+
alias="passQueryParams",
6971
)
7072
pass_json_body_params: List[str] = Field(
7173
default=[],
7274
description="JSON body parameters to extract and pass to the upstream API",
75+
alias="passJsonBodyParams",
7376
)
7477
pass_form_data_params: List[str] = Field(
7578
default=[],
7679
description="Form data parameters to extract and pass to the upstream API",
80+
alias="passFormDataParams",
7781
)
7882

83+
model_config = ConfigDict(populate_by_name=True)
84+
7985

8086
class UpsertDeploymentRequest(BaseModel):
8187
"""Request to deploy or update an MCP server."""
8288

83-
open_api_spec: OpenAPISpec = Field(..., description="The OpenAPI specification")
89+
open_api_spec: OpenAPISpec = Field(..., description="The OpenAPI specification", alias="openApiSpec")
8490
name: Optional[str] = Field(None, description="Optional name for the deployment")
85-
base_url: Optional[str] = Field(None, description="Base URL of the API to proxy requests to")
91+
base_url: Optional[str] = Field(None, description="Base URL of the API to proxy requests to", alias="baseUrl")
8692
auth_config: AuthConfig = Field(
87-
default_factory=AuthConfig,
88-
description="Configuration for authentication handling",
93+
default_factory=AuthConfig, description="Configuration for authentication handling", alias="authConfig"
8994
)
9095

96+
model_config = ConfigDict(populate_by_name=True)
97+
9198

9299
class DeploymentResponseData(BaseModel):
93100
"""Deployment data in a successful response."""
94101

95102
id: str
96-
created_at: Optional[datetime] = None
97-
created_by: str
98-
updated_by: str
99-
mcp_server_id: str
100-
open_api_spec_hash: str
101-
mcp_spec_hash: str
102-
status: str
103+
created_at: Optional[datetime] = Field(None, alias="createdAt")
104+
created_by: Optional[str] = Field(None, alias="createdBy")
105+
updated_by: Optional[str] = Field(None, alias="updatedBy")
106+
mcp_server_id: Optional[str] = Field(None, alias="mcpServerId")
107+
open_api_spec_hash: Optional[str] = Field(None, alias="openAPISpecHash")
108+
mcp_spec_hash: Optional[str] = Field(None, alias="mcpSpecHash")
109+
status: Optional[str] = Field(None)
110+
111+
model_config = ConfigDict(populate_by_name=True, extra="allow")
103112

104113

105114
class UpsertDeploymentResponseData(BaseModel):
@@ -108,6 +117,8 @@ class UpsertDeploymentResponseData(BaseModel):
108117
updated: bool
109118
deployment: DeploymentResponseData
110119

120+
model_config = ConfigDict(populate_by_name=True)
121+
111122

112123
class DeploymentResponse(ApiResponse):
113124
"""API response for deployment operations."""

tadata_sdk/openapi/source.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class OpenAPIInfo(BaseModel):
1515
version: str
1616
description: Optional[str] = None
1717

18+
model_config = ConfigDict(populate_by_name=True)
19+
1820

1921
class OpenAPISpec(BaseModel):
2022
"""Represents a validated OpenAPI specification.
@@ -26,7 +28,7 @@ class OpenAPISpec(BaseModel):
2628
openapi: str = Field(..., description="OpenAPI version string")
2729
info: OpenAPIInfo = Field(..., description="Information about the API")
2830
paths: Dict[str, Any] = Field(..., description="API paths")
29-
model_config = ConfigDict(extra="allow")
31+
model_config = ConfigDict(extra="allow", populate_by_name=True)
3032

3133
@field_validator("openapi")
3234
@classmethod

uv.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)