@@ -86,7 +86,7 @@ func ResourceFileSystemCreate(ctx context.Context, d *schema.ResourceData, m int
8686 Region : region ,
8787 Name : types .ExpandOrGenerateString (d .Get ("name" ).(string ), "file" ),
8888 ProjectID : d .Get ("project_id" ).(string ),
89- Size : * types .ExpandUint64Ptr (d .Get ("size" )),
89+ Size : types .ExpandUint64Ptr (d .Get ("size" )),
9090 Tags : types .ExpandStrings (d .Get ("tags" )),
9191 }
9292
@@ -154,34 +154,55 @@ func ResourceFileSystemUpdate(ctx context.Context, d *schema.ResourceData, m int
154154 }
155155
156156 req := & file.UpdateFileSystemRequest {
157- Region : region ,
157+ Region : region ,
158158 FilesystemID : fileSystem .ID ,
159159 }
160160
161161 if d .HasChange ("name" ) {
162162 req .Name = types .ExpandUpdatedStringPtr (d .Get ("name" ))
163163 }
164164
165- // // Region: region to target. If none is passed will use default region from the config.
166- // Region scw.Region `json:"-"`
167-
168- // // FilesystemID: UUID of the filesystem.
169- // FilesystemID string `json:"-"`
170-
171- // // Name: when defined, is the new name of the filesystem.
172- // Name *string `json:"name,omitempty"`
165+ if d .HasChange ("size" ) {
166+ req .Size = types .ExpandUint64Ptr (d .Get ("size" ))
167+ }
173168
174- // // Size: size in bytes, with a granularity of 100 GB (10^11 bytes).
175- // // Must be compliant with the minimum (100 GB) and maximum (10 TB) allowed size.
176- // Size *uint64 `json:"size,omitempty"`
169+ if d . HasChange ( "tags" ) {
170+ req . Tags = types . ExpandStringsPtr ( d . Get ( "tags" ))
171+ }
177172
178- // // Tags: list of tags assigned to the filesystem.
179- // Tags *[]string `json:"tags,omitempty"`
173+ if _ , err := api .UpdateFileSystem (req , scw .WithContext (ctx )); err != nil {
174+ return diag .FromErr (err )
175+ }
180176
181177 return ResourceFileSystemRead (ctx , d , m )
182178}
183179
184180func ResourceFileSystemDelete (ctx context.Context , d * schema.ResourceData , m interface {}) diag.Diagnostics {
181+ api , region , id , err := NewAPIWithRegionAndID (m , d .Id ())
182+ if err != nil {
183+ return diag .FromErr (err )
184+ }
185+
186+ _ , err = waitForFileSystem (ctx , api , region , id , d .Timeout (schema .TimeoutDelete ))
187+ if err != nil {
188+ if httperrors .Is404 (err ) {
189+ d .SetId ("" )
190+
191+ return nil
192+ }
193+
194+ return diag .FromErr (err )
195+ }
196+
197+ err = api .DeleteFileSystem (& file.DeleteFileSystemRequest {
198+ Region : region ,
199+ FilesystemID : id ,
200+ })
201+
202+ _ , err = waitForFileSystem (ctx , api , region , id , d .Timeout (schema .TimeoutDelete ))
203+ if err != nil && ! httperrors .Is404 (err ) {
204+ return diag .FromErr (err )
205+ }
185206
186207 return nil
187208}
0 commit comments