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

add method to patch an image #188

Merged
merged 2 commits into from
Nov 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions coder-sdk/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ type ImportImageReq struct {
URL string `json:"url"`
}

// UpdateImageReq defines the requests parameters for a partial update of an image resource.
type UpdateImageReq struct {
DefaultCPUCores *float32 `json:"default_cpu_cores"`
DefaultMemoryGB *int `json:"default_memory_gb"`
DefaultDiskGB *int `json:"default_disk_gb"`
Description *string `json:"description"`
URL *string `json:"url"`
Deprecated *bool `json:"deprecated"`
DefaultTag *string `json:"default_tag"`
}

// ImportImage creates a new image and optionally a new registry.
func (c Client) ImportImage(ctx context.Context, orgID string, req ImportImageReq) (*Image, error) {
var img Image
Expand All @@ -61,3 +72,8 @@ func (c Client) OrganizationImages(ctx context.Context, orgID string) ([]Image,
}
return imgs, nil
}

// UpdateImage applies a partial update to an image resource.
func (c Client) UpdateImage(ctx context.Context, imageID string, req UpdateImageReq) error {
return c.requestBody(ctx, http.MethodPatch, "/api/images/"+imageID, req, nil)
}