@@ -380,6 +380,25 @@ type ScalewayServer struct {
380
380
Organization string `json:"organization,omitempty"`
381
381
}
382
382
383
+ // ScalewayServerPatchDefinition represents a Scaleway C1 server with nullable fields (for PATCH)
384
+ type ScalewayServerPatchDefinition struct {
385
+ Name * string `json:"name,omitempty"`
386
+ CreationDate * string `json:"creation_date,omitempty"`
387
+ ModificationDate * string `json:"modification_date,omitempty"`
388
+ Image * ScalewayImage `json:"image,omitempty"`
389
+ DynamicIPRequired * bool `json:"dynamic_ip_required,omitempty"`
390
+ PublicAddress * ScalewayIPAddress `json:"public_ip,omitempty"`
391
+ State * string `json:"state,omitempty"`
392
+ StateDetail * string `json:"state_detail,omitempty"`
393
+ PrivateIP * string `json:"private_ip,omitempty"`
394
+ Bootscript * ScalewayBootscript `json:"bootscript,omitempty"`
395
+ Hostname * string `json:"hostname,omitempty"`
396
+ Volumes * map [string ]ScalewayVolume `json:"volumes,omitempty"`
397
+ SecurityGroup * ScalewaySecurityGroup `json:"security_group,omitempty"`
398
+ Organization * string `json:"organization,omitempty"`
399
+ //Tags *[]string `json:"tags",omitempty`
400
+ }
401
+
383
402
// ScalewayServerPatchNameDefinition represents a Scaleway C1 server with only its name as field
384
403
type ScalewayServerPatchNameDefinition struct {
385
404
// Name is the user-defined name of the server
@@ -708,6 +727,32 @@ func (s *ScalewayAPI) PatchServerName(serverID string, definition ScalewayServer
708
727
return error
709
728
}
710
729
730
+ // PatchServer updates a server
731
+ func (s * ScalewayAPI ) PatchServer (serverID string , definition ScalewayServerPatchDefinition ) error {
732
+ resp , err := s .PatchResponse (fmt .Sprintf ("servers/%s" , serverID ), definition )
733
+ if err != nil {
734
+ return err
735
+ }
736
+
737
+ defer resp .Body .Close ()
738
+ decoder := json .NewDecoder (resp .Body )
739
+
740
+ // Succeed PATCH code
741
+ if resp .StatusCode == 200 {
742
+ return nil
743
+ }
744
+
745
+ var error ScalewayAPIError
746
+ err = decoder .Decode (& error )
747
+ if err != nil {
748
+ return err
749
+ }
750
+
751
+ error .StatusCode = resp .StatusCode
752
+ error .Debug ()
753
+ return error
754
+ }
755
+
711
756
// PostSnapshot creates a new snapshot
712
757
func (s * ScalewayAPI ) PostSnapshot (volumeID string , name string ) (string , error ) {
713
758
definition := ScalewaySnapshotDefinition {
0 commit comments