@@ -3,6 +3,7 @@ package coder
3
3
import (
4
4
"context"
5
5
"net/http"
6
+ "net/url"
6
7
"time"
7
8
)
8
9
@@ -36,6 +37,7 @@ type ImportImageReq struct {
36
37
RegistryID * string `json:"registry_id"` // Used to import images to existing registries.
37
38
NewRegistry * NewRegistryRequest `json:"new_registry"` // Used when adding a new registry.
38
39
Repository string `json:"repository"` // Refers to the image. Ex: "codercom/ubuntu".
40
+ OrgID string `json:"org_id"`
39
41
Tag string `json:"tag"`
40
42
DefaultCPUCores float32 `json:"default_cpu_cores"`
41
43
DefaultMemoryGB int `json:"default_memory_gb"`
@@ -56,29 +58,35 @@ type UpdateImageReq struct {
56
58
}
57
59
58
60
// ImportImage creates a new image and optionally a new registry.
59
- func (c Client ) ImportImage (ctx context.Context , orgID string , req ImportImageReq ) (* Image , error ) {
61
+ func (c Client ) ImportImage (ctx context.Context , req ImportImageReq ) (* Image , error ) {
60
62
var img Image
61
- if err := c .requestBody (ctx , http .MethodPost , "/api/private/orgs/" + orgID + " /images" , req , & img ); err != nil {
63
+ if err := c .requestBody (ctx , http .MethodPost , "/api/v0 /images" , req , & img ); err != nil {
62
64
return nil , err
63
65
}
64
66
return & img , nil
65
67
}
66
68
67
69
// OrganizationImages returns all of the images imported for orgID.
68
70
func (c Client ) OrganizationImages (ctx context.Context , orgID string ) ([]Image , error ) {
69
- var imgs []Image
70
- if err := c .requestBody (ctx , http .MethodGet , "/api/private/orgs/" + orgID + "/images" , nil , & imgs ); err != nil {
71
+ var (
72
+ imgs []Image
73
+ query = url.Values {}
74
+ )
75
+
76
+ query .Set ("org" , orgID )
77
+
78
+ if err := c .requestBody (ctx , http .MethodGet , "/api/v0/images" , nil , & imgs , withQueryParams (query )); err != nil {
71
79
return nil , err
72
80
}
73
81
return imgs , nil
74
82
}
75
83
76
84
// UpdateImage applies a partial update to an image resource.
77
85
func (c Client ) UpdateImage (ctx context.Context , imageID string , req UpdateImageReq ) error {
78
- return c .requestBody (ctx , http .MethodPatch , "/api/private /images/" + imageID , req , nil )
86
+ return c .requestBody (ctx , http .MethodPatch , "/api/v0 /images/" + imageID , req , nil )
79
87
}
80
88
81
89
// UpdateImageTags refreshes the latest digests for all tags of the image.
82
90
func (c Client ) UpdateImageTags (ctx context.Context , imageID string ) error {
83
- return c .requestBody (ctx , http .MethodPost , "/api/private /images/" + imageID + "/tags/update" , nil , nil )
91
+ return c .requestBody (ctx , http .MethodPost , "/api/v0 /images/" + imageID + "/tags/update" , nil , nil )
84
92
}
0 commit comments