Skip to content

Commit afbc3d9

Browse files
jsell-rhclaude
andcommitted
fix(sdk): use .ReturnType in Go and Python action templates
Aligns Go and Python templates with the TS template by using the Action's .ReturnType field instead of hardcoding $.Resource.Name. Currently equivalent since the parser only returns the resource name or empty string, but this is more consistent and future-proof. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c6de652 commit afbc3d9

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

components/ambient-sdk/generator/templates/go/client.go.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ func (a *{{.Resource.Name}}API) UpdateStatus(ctx context.Context, id string, pat
117117
{{end}}
118118
{{- range .Resource.Actions}}
119119
{{- if .ReturnType}}
120-
func (a *{{$.Resource.Name}}API) {{.Name | title}}(ctx context.Context, id string) (*types.{{$.Resource.Name}}, error) {
121-
var result types.{{$.Resource.Name}}
120+
func (a *{{$.Resource.Name}}API) {{.Name | title}}(ctx context.Context, id string) (*types.{{.ReturnType}}, error) {
121+
var result types.{{.ReturnType}}
122122
{{- if $.Resource.IsSubResource}}
123123
if err := a.client.do(ctx, http.Method{{.Method | title}}, a.basePath()+"/"+url.PathEscape(id)+"/{{.Name}}", nil, http.StatusOK, &result); err != nil {
124124
{{- else}}

components/ambient-sdk/generator/templates/python/client.py.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ class {{.Resource.Name}}API:
8181
{{end}}
8282
{{- range .Resource.Actions}}
8383
{{- if .ReturnType}}
84-
def {{.Name}}(self, resource_id: str) -> {{$.Resource.Name}}:
84+
def {{.Name}}(self, resource_id: str) -> {{.ReturnType}}:
8585
{{- if $.Resource.IsSubResource}}
8686
resp = self._client._request("{{.Method | upper}}", f"{self._base_path()}/{resource_id}/{{.Name}}")
8787
{{- else}}
8888
resp = self._client._request("{{.Method | upper}}", f"/{{$.Resource.PathSegment}}/{resource_id}/{{.Name}}")
8989
{{- end}}
90-
return {{$.Resource.Name}}.from_dict(resp)
90+
return {{.ReturnType}}.from_dict(resp)
9191
{{- else}}
9292
def {{.Name}}(self, resource_id: str) -> dict:
9393
{{- if $.Resource.IsSubResource}}

0 commit comments

Comments
 (0)