@@ -19,13 +19,7 @@ import (
1919// the resource will be assumed to be a project-level resource (like a connector or flow), otherwise
2020// it'll be assumed to be a company-level resource.
2121func newResource [T any , M helpers.ResourceModel [T ]](name string , sc schema.Schema ) resource.Resource {
22- return & baseResource [T , M ]{name : name , entity : name , schema : sc }
23- }
24-
25- // Like newResource but with a distinct API entity name, for when the user-facing resource name
26- // differs from the infra entity the backend expects (e.g. descope_custom_language -> custom_locale).
27- func newResourceWithEntity [T any , M helpers.ResourceModel [T ]](name , entity string , sc schema.Schema ) resource.Resource {
28- return & baseResource [T , M ]{name : name , entity : entity , schema : sc }
22+ return & baseResource [T , M ]{name : name , schema : sc }
2923}
3024
3125// Use a random model to ensure interface conformance
3630)
3731
3832type baseResource [T any , M helpers.ResourceModel [T ]] struct {
39- name string // user-facing resource name (descope_<name>)
40- entity string // infra entity name sent to the backend; defaults to name
33+ name string
4134 schema schema.Schema
4235 client * infra.Client
4336}
@@ -71,7 +64,7 @@ func (r *baseResource[T, M]) Create(ctx context.Context, req resource.CreateRequ
7164 return
7265 }
7366
74- res , err := r .client .Create (ctx , model .GetProjectID ().ValueString (), r .entity , values )
67+ res , err := r .client .Create (ctx , model .GetProjectID ().ValueString (), r .name , values )
7568 if failure , ok := infra .AsValidationError (err ); ok {
7669 resp .Diagnostics .AddError ("Invalid " + r .name + " configuration" , failure )
7770 return
@@ -98,7 +91,7 @@ func (r *baseResource[T, M]) Read(ctx context.Context, req resource.ReadRequest,
9891 return
9992 }
10093
101- res , err := r .client .Read (ctx , model .GetProjectID ().ValueString (), r .entity , model .GetID ().ValueString ())
94+ res , err := r .client .Read (ctx , model .GetProjectID ().ValueString (), r .name , model .GetID ().ValueString ())
10295 if err != nil {
10396 resp .Diagnostics .AddError ("Error reading " + r .name , err .Error ())
10497 return
@@ -126,7 +119,7 @@ func (r *baseResource[T, M]) Update(ctx context.Context, req resource.UpdateRequ
126119 return
127120 }
128121
129- res , err := r .client .Update (ctx , model .GetProjectID ().ValueString (), r .entity , model .GetID ().ValueString (), values )
122+ res , err := r .client .Update (ctx , model .GetProjectID ().ValueString (), r .name , model .GetID ().ValueString (), values )
130123 if failure , ok := infra .AsValidationError (err ); ok {
131124 resp .Diagnostics .AddError ("Invalid " + r .name + " configuration" , failure )
132125 return
@@ -151,7 +144,7 @@ func (r *baseResource[T, M]) Delete(ctx context.Context, req resource.DeleteRequ
151144 return
152145 }
153146
154- err := r .client .Delete (ctx , model .GetProjectID ().ValueString (), r .entity , model .GetID ().ValueString ())
147+ err := r .client .Delete (ctx , model .GetProjectID ().ValueString (), r .name , model .GetID ().ValueString ())
155148 if err != nil {
156149 resp .Diagnostics .AddError ("Error deleting " + r .name , err .Error ())
157150 return
0 commit comments