diff --git a/apiclient/types/oauthapp.go b/apiclient/types/oauthapp.go index 4bf607d27..d3efa0d06 100644 --- a/apiclient/types/oauthapp.go +++ b/apiclient/types/oauthapp.go @@ -14,7 +14,7 @@ type OAuthAppType string type OAuthApp struct { OAuthAppManifest - OAuthAppExternalStatus + RefNameAssigned bool `json:"refNameAssigned,omitempty"` } type OAuthAppManifest struct { diff --git a/apiclient/types/webhook.go b/apiclient/types/webhook.go index 6d8f0a1b0..3e1baafcf 100644 --- a/apiclient/types/webhook.go +++ b/apiclient/types/webhook.go @@ -3,7 +3,7 @@ package types type Webhook struct { Metadata WebhookManifest - WebhookExternalStatus + RefNameAssigned bool `json:"refNameAssigned,omitempty"` LastSuccessfulRunCompleted *Time `json:"lastSuccessfulRunCompleted,omitempty"` } diff --git a/apiclient/types/zz_generated.deepcopy.go b/apiclient/types/zz_generated.deepcopy.go index f150227ce..eca90e21e 100644 --- a/apiclient/types/zz_generated.deepcopy.go +++ b/apiclient/types/zz_generated.deepcopy.go @@ -526,7 +526,6 @@ func (in *NotionPage) DeepCopy() *NotionPage { func (in *OAuthApp) DeepCopyInto(out *OAuthApp) { *out = *in in.OAuthAppManifest.DeepCopyInto(&out.OAuthAppManifest) - out.OAuthAppExternalStatus = in.OAuthAppExternalStatus } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OAuthApp. @@ -1211,7 +1210,6 @@ func (in *Webhook) DeepCopyInto(out *Webhook) { *out = *in in.Metadata.DeepCopyInto(&out.Metadata) in.WebhookManifest.DeepCopyInto(&out.WebhookManifest) - out.WebhookExternalStatus = in.WebhookExternalStatus if in.LastSuccessfulRunCompleted != nil { in, out := &in.LastSuccessfulRunCompleted, &out.LastSuccessfulRunCompleted *out = (*in).DeepCopy() diff --git a/pkg/api/handlers/webhooks.go b/pkg/api/handlers/webhooks.go index 8dda0413e..5ac012fef 100644 --- a/pkg/api/handlers/webhooks.go +++ b/pkg/api/handlers/webhooks.go @@ -108,10 +108,12 @@ func convertWebhook(webhook v1.Webhook, urlPrefix string) *types.Webhook { links = []string{"invoke", fmt.Sprintf("%s/webhooks/%s", urlPrefix, webhook.Status.External.RefName)} } + manifest := webhook.Spec.WebhookManifest + manifest.RefName = webhook.Status.External.RefName wh := &types.Webhook{ Metadata: MetadataFrom(&webhook, links...), - WebhookManifest: webhook.Spec.WebhookManifest, - WebhookExternalStatus: webhook.Status.External, + WebhookManifest: manifest, + RefNameAssigned: webhook.Status.External.RefNameAssigned, LastSuccessfulRunCompleted: v1.NewTime(webhook.Status.LastSuccessfulRunCompleted), } diff --git a/pkg/gateway/server/oauth_apps.go b/pkg/gateway/server/oauth_apps.go index 26041dd1d..927b66f06 100644 --- a/pkg/gateway/server/oauth_apps.go +++ b/pkg/gateway/server/oauth_apps.go @@ -124,8 +124,8 @@ func (s *Server) createOAuthApp(apiContext api.Context) error { // updateOAuthApp updates an existing OAuth app registration in the database (admin only). func (s *Server) updateOAuthApp(apiContext api.Context) error { - appManifest := new(types2.OAuthAppManifest) - if err := apiContext.Read(appManifest); err != nil { + var appManifest types2.OAuthAppManifest + if err := apiContext.Read(&appManifest); err != nil { return apierrors.NewBadRequest(fmt.Sprintf("invalid OAuth app: %s", err)) } @@ -135,13 +135,13 @@ func (s *Server) updateOAuthApp(apiContext api.Context) error { return err } - merged := types.MergeOAuthAppManifests(&originalApp.Spec.Manifest, appManifest) - if err := types.ValidateAndSetDefaultsOAuthAppManifest(merged); err != nil { + merged := types.MergeOAuthAppManifests(originalApp.Spec.Manifest, appManifest) + if err := types.ValidateAndSetDefaultsOAuthAppManifest(&merged); err != nil { return apierrors.NewBadRequest(fmt.Sprintf("invalid OAuth app: %s", err)) } // Update the app. - originalApp.Spec.Manifest = *merged + originalApp.Spec.Manifest = merged if err := apiContext.Update(&originalApp); err != nil { return err } @@ -512,9 +512,10 @@ func convertOAuthAppRegistrationToOAuthApp(app v1.OAuthApp, baseURL string) type links = append(links, "refreshURL", refreshURL) } appManifest.Metadata = handlers.MetadataFrom(&app, links...) + appManifest.RefName = app.Status.External.RefName return types2.OAuthApp{ - OAuthAppManifest: appManifest, - OAuthAppExternalStatus: app.Status.External, + OAuthAppManifest: appManifest, + RefNameAssigned: app.Status.External.RefNameAssigned, } } diff --git a/pkg/gateway/types/oauth_apps.go b/pkg/gateway/types/oauth_apps.go index 6c6ed5a23..3cc217554 100644 --- a/pkg/gateway/types/oauth_apps.go +++ b/pkg/gateway/types/oauth_apps.go @@ -146,8 +146,8 @@ func ValidateAndSetDefaultsOAuthAppManifest(r *types.OAuthAppManifest) error { return errors.Join(errs...) } -func MergeOAuthAppManifests(r, other *types.OAuthAppManifest) *types.OAuthAppManifest { - retVal := *r +func MergeOAuthAppManifests(r, other types.OAuthAppManifest) types.OAuthAppManifest { + retVal := r if other.RefName != "" { retVal.RefName = other.RefName @@ -167,8 +167,11 @@ func MergeOAuthAppManifests(r, other *types.OAuthAppManifest) *types.OAuthAppMan if other.TenantID != "" { retVal.TenantID = other.TenantID } + if other.Name != "" { + retVal.Name = other.Name + } - return &retVal + return retVal } // OAuthTokenResponse represents a response from the /token endpoint on an OAuth server. diff --git a/pkg/storage/openapi/generated/openapi_generated.go b/pkg/storage/openapi/generated/openapi_generated.go index e16a90b53..fb0801c2c 100644 --- a/pkg/storage/openapi/generated/openapi_generated.go +++ b/pkg/storage/openapi/generated/openapi_generated.go @@ -1198,18 +1198,18 @@ func schema_otto8_ai_otto8_apiclient_types_OAuthApp(ref common.ReferenceCallback Ref: ref("github.com/otto8-ai/otto8/apiclient/types.OAuthAppManifest"), }, }, - "OAuthAppExternalStatus": { + "refNameAssigned": { SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("github.com/otto8-ai/otto8/apiclient/types.OAuthAppExternalStatus"), + Type: []string{"boolean"}, + Format: "", }, }, }, - Required: []string{"OAuthAppManifest", "OAuthAppExternalStatus"}, + Required: []string{"OAuthAppManifest"}, }, }, Dependencies: []string{ - "github.com/otto8-ai/otto8/apiclient/types.OAuthAppExternalStatus", "github.com/otto8-ai/otto8/apiclient/types.OAuthAppManifest"}, + "github.com/otto8-ai/otto8/apiclient/types.OAuthAppManifest"}, } } @@ -2644,10 +2644,10 @@ func schema_otto8_ai_otto8_apiclient_types_Webhook(ref common.ReferenceCallback) Ref: ref("github.com/otto8-ai/otto8/apiclient/types.WebhookManifest"), }, }, - "WebhookExternalStatus": { + "refNameAssigned": { SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("github.com/otto8-ai/otto8/apiclient/types.WebhookExternalStatus"), + Type: []string{"boolean"}, + Format: "", }, }, "lastSuccessfulRunCompleted": { @@ -2656,11 +2656,11 @@ func schema_otto8_ai_otto8_apiclient_types_Webhook(ref common.ReferenceCallback) }, }, }, - Required: []string{"Metadata", "WebhookManifest", "WebhookExternalStatus"}, + Required: []string{"Metadata", "WebhookManifest"}, }, }, Dependencies: []string{ - "github.com/otto8-ai/otto8/apiclient/types.Metadata", "github.com/otto8-ai/otto8/apiclient/types.Time", "github.com/otto8-ai/otto8/apiclient/types.WebhookExternalStatus", "github.com/otto8-ai/otto8/apiclient/types.WebhookManifest"}, + "github.com/otto8-ai/otto8/apiclient/types.Metadata", "github.com/otto8-ai/otto8/apiclient/types.Time", "github.com/otto8-ai/otto8/apiclient/types.WebhookManifest"}, } }