@@ -124,7 +124,7 @@ func ResourceCustomModel() *schema.Resource {
124124 Computed : true ,
125125 Description : "Size, in bits, of the model parameters" ,
126126 },
127- "size_bits " : {
127+ "size_bytes " : {
128128 Type : schema .TypeInt ,
129129 Computed : true ,
130130 Description : "Total size, in bytes, of the model files" ,
@@ -161,7 +161,7 @@ func ResourceCustomModelCreate(ctx context.Context, d *schema.ResourceData, m in
161161 return diag .FromErr (err )
162162 }
163163
164- d .SetId (regional . NewIDString ( region , model .ID ) )
164+ d .SetId (model .ID )
165165
166166 model , err = waitForModel (ctx , api , region , model .ID , d .Timeout (schema .TimeoutCreate ))
167167 if err != nil {
@@ -178,12 +178,12 @@ func ResourceCustomModelCreate(ctx context.Context, d *schema.ResourceData, m in
178178}
179179
180180func ResourceCustomModelRead (ctx context.Context , d * schema.ResourceData , m interface {}) diag.Diagnostics {
181- api , region , id , err := NewAPIWithRegionAndID ( m , d . Id () )
181+ api , region , err := NewAPIWithRegion ( d , m )
182182 if err != nil {
183183 return diag .FromErr (err )
184184 }
185185
186- model , err := waitForModel (ctx , api , region , id , d .Timeout (schema .TimeoutRead ))
186+ model , err := waitForModel (ctx , api , region , d . Id () , d .Timeout (schema .TimeoutRead ))
187187 if err != nil {
188188 if httperrors .Is404 (err ) {
189189 d .SetId ("" )
@@ -195,7 +195,7 @@ func ResourceCustomModelRead(ctx context.Context, d *schema.ResourceData, m inte
195195 }
196196
197197 _ = d .Set ("parameter_size_bits" , int32 (model .ParameterSizeBits ))
198- _ = d .Set ("size_bits " , int64 (model .SizeBytes ))
198+ _ = d .Set ("size_bytes " , int64 (model .SizeBytes ))
199199 _ = d .Set ("name" , model .Name )
200200 _ = d .Set ("status" , model .Status )
201201 _ = d .Set ("description" , model .Description )
@@ -209,23 +209,18 @@ func ResourceCustomModelRead(ctx context.Context, d *schema.ResourceData, m inte
209209}
210210
211211func ResourceCustomModelDelete (ctx context.Context , d * schema.ResourceData , m interface {}) diag.Diagnostics {
212- api , region , id , err := NewAPIWithRegionAndID ( m , d . Id () )
212+ api , region , err := NewAPIWithRegion ( d , m )
213213 if err != nil {
214214 return diag .FromErr (err )
215215 }
216216
217- _ , err = waitForModel (ctx , api , region , id , d .Timeout (schema .TimeoutDelete ))
217+ _ , err = waitForModel (ctx , api , region , d . Id () , d .Timeout (schema .TimeoutDelete ))
218218 if err != nil {
219219 return diag .FromErr (err )
220220 }
221221
222- err = api .DeleteModel (& inference.DeleteModelRequest {
222+ return diag . FromErr ( api .DeleteModel (& inference.DeleteModelRequest {
223223 Region : region ,
224- ModelID : id ,
225- }, scw .WithContext (ctx ))
226- if err != nil {
227- return diag .FromErr (err )
228- }
229-
230- return nil
224+ ModelID : d .Id (),
225+ }, scw .WithContext (ctx )))
231226}
0 commit comments