diff --git a/api/instance/v1/instance_sdk.go b/api/instance/v1/instance_sdk.go index 99d6f1154..feda98802 100644 --- a/api/instance/v1/instance_sdk.go +++ b/api/instance/v1/instance_sdk.go @@ -919,6 +919,10 @@ type Dashboard struct { IPsUnused uint32 `json:"ips_unused"` } +type ExportSnapshotResponse struct { + Task *Task `json:"task"` +} + type GetBootscriptResponse struct { Bootscript *Bootscript `json:"bootscript"` } @@ -1528,6 +1532,8 @@ type Snapshot struct { ModificationDate *time.Time `json:"modification_date"` // Zone: the snapshot zone Zone scw.Zone `json:"zone"` + // ErrorReason: the reason for the failed snapshot import + ErrorReason *string `json:"error_reason"` } // SnapshotBaseVolume: snapshot. base volume @@ -2963,9 +2969,15 @@ type CreateSnapshotRequest struct { // // Default value: unknown_volume_type VolumeType SnapshotVolumeType `json:"volume_type"` + // Bucket: bucket name for snapshot imports + Bucket *string `json:"bucket,omitempty"` + // Key: object key for snapshot imports + Key *string `json:"key,omitempty"` + // Size: imported snapshot size, must be a multiple of 512 + Size *scw.Size `json:"size,omitempty"` } -// CreateSnapshot: create a snapshot from a given volume +// CreateSnapshot: create a snapshot from a given volume or from a QCOW2 file func (s *API) CreateSnapshot(req *CreateSnapshotRequest, opts ...scw.RequestOption) (*CreateSnapshotResponse, error) { var err error @@ -3180,6 +3192,58 @@ func (s *API) DeleteSnapshot(req *DeleteSnapshotRequest, opts ...scw.RequestOpti return nil } +type ExportSnapshotRequest struct { + // Zone: + // + // Zone to target. If none is passed will use default zone from the config + Zone scw.Zone `json:"-"` + // SnapshotID: the snapshot ID + SnapshotID string `json:"-"` + // Bucket: s3 bucket name + Bucket string `json:"bucket,omitempty"` + // Key: s3 object key + Key string `json:"key,omitempty"` +} + +// ExportSnapshot: export a snapshot +// +// Export a snapshot to a given S3 bucket in the same region. +func (s *API) ExportSnapshot(req *ExportSnapshotRequest, opts ...scw.RequestOption) (*ExportSnapshotResponse, error) { + var err error + + if req.Zone == "" { + defaultZone, _ := s.client.GetDefaultZone() + req.Zone = defaultZone + } + + if fmt.Sprint(req.Zone) == "" { + return nil, errors.New("field Zone cannot be empty in request") + } + + if fmt.Sprint(req.SnapshotID) == "" { + return nil, errors.New("field SnapshotID cannot be empty in request") + } + + scwReq := &scw.ScalewayRequest{ + Method: "POST", + Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/snapshots/" + fmt.Sprint(req.SnapshotID) + "/export", + Headers: http.Header{}, + } + + err = scwReq.SetBody(req) + if err != nil { + return nil, err + } + + var resp ExportSnapshotResponse + + err = s.client.Do(scwReq, &resp, opts...) + if err != nil { + return nil, err + } + return &resp, nil +} + type ListVolumesRequest struct { // Zone: // diff --git a/api/rdb/v1/rdb_sdk.go b/api/rdb/v1/rdb_sdk.go index 6e2afb9cb..fb836c5b0 100644 --- a/api/rdb/v1/rdb_sdk.go +++ b/api/rdb/v1/rdb_sdk.go @@ -2444,6 +2444,8 @@ type CreateReadReplicaRequest struct { } // CreateReadReplica: create a read replica +// +// You can only create a maximum of 3 read replicas for one instance. func (s *API) CreateReadReplica(req *CreateReadReplicaRequest, opts ...scw.RequestOption) (*ReadReplica, error) { var err error @@ -2568,6 +2570,10 @@ type ResetReadReplicaRequest struct { } // ResetReadReplica: reset a read replica +// +// Resetting a read replica resyncs data from the leader node. This operation can take some time, depending on the database's size. +// During this operation, the read replica will not be available. Endpoints will not change. +// func (s *API) ResetReadReplica(req *ResetReadReplicaRequest, opts ...scw.RequestOption) (*ReadReplica, error) { var err error @@ -2616,6 +2622,8 @@ type CreateReadReplicaEndpointRequest struct { } // CreateReadReplicaEndpoint: create a new endpoint for a given read replica +// +// A read replica can have at most one direct access and one private network endpoint. func (s *API) CreateReadReplicaEndpoint(req *CreateReadReplicaEndpointRequest, opts ...scw.RequestOption) (*ReadReplica, error) { var err error @@ -4084,6 +4092,8 @@ type DeleteEndpointRequest struct { // Region to target. If none is passed will use default region from the config Region scw.Region `json:"-"` // EndpointID: UUID of the endpoint you want to delete + // + // This endpoint can also be used to delete a read replica endpoint. EndpointID string `json:"-"` }