Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit 8ebcfd1

Browse files
authored
Merge pull request #188 from jmcampanini/jc/add-updateimage
add method to patch an image
2 parents ce06c53 + b7fbf9c commit 8ebcfd1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

coder-sdk/image.go

+16
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@ type ImportImageReq struct {
4444
URL string `json:"url"`
4545
}
4646

47+
// UpdateImageReq defines the requests parameters for a partial update of an image resource.
48+
type UpdateImageReq struct {
49+
DefaultCPUCores *float32 `json:"default_cpu_cores"`
50+
DefaultMemoryGB *int `json:"default_memory_gb"`
51+
DefaultDiskGB *int `json:"default_disk_gb"`
52+
Description *string `json:"description"`
53+
URL *string `json:"url"`
54+
Deprecated *bool `json:"deprecated"`
55+
DefaultTag *string `json:"default_tag"`
56+
}
57+
4758
// ImportImage creates a new image and optionally a new registry.
4859
func (c Client) ImportImage(ctx context.Context, orgID string, req ImportImageReq) (*Image, error) {
4960
var img Image
@@ -61,3 +72,8 @@ func (c Client) OrganizationImages(ctx context.Context, orgID string) ([]Image,
6172
}
6273
return imgs, nil
6374
}
75+
76+
// UpdateImage applies a partial update to an image resource.
77+
func (c Client) UpdateImage(ctx context.Context, imageID string, req UpdateImageReq) error {
78+
return c.requestBody(ctx, http.MethodPatch, "/api/images/"+imageID, req, nil)
79+
}

0 commit comments

Comments
 (0)