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

Commit fca4520

Browse files
committed
Add create registry to sdk
1 parent 9b94c77 commit fca4520

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

coder-sdk/registries.go

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ func (c Client) Registries(ctx context.Context, orgID string) ([]Registry, error
2626
}
2727

2828
// RegistryByID fetches a registry resource by its ID.
29-
func (c Client) RegistryByID(ctx context.Context, orgID, registryID string) (*Registry, error) {
29+
func (c Client) RegistryByID(ctx context.Context, registryID string) (*Registry, error) {
3030
var r Registry
31-
if err := c.requestBody(ctx, http.MethodGet, "/api/private/orgs/"+orgID+"/registries/"+registryID, nil, &r); err != nil {
31+
if err := c.requestBody(ctx, http.MethodGet, "/api/private/registries/"+registryID, nil, &r); err != nil {
3232
return nil, err
3333
}
3434
return &r, nil
@@ -43,11 +43,28 @@ type UpdateRegistryReq struct {
4343
}
4444

4545
// UpdateRegistry applies a partial update to a registry resource.
46-
func (c Client) UpdateRegistry(ctx context.Context, orgID, registryID string, req UpdateRegistryReq) error {
47-
return c.requestBody(ctx, http.MethodPatch, "/api/private/orgs/"+orgID+"/registries/"+registryID, req, nil)
46+
func (c Client) UpdateRegistry(ctx context.Context, registryID string, req UpdateRegistryReq) error {
47+
return c.requestBody(ctx, http.MethodPatch, "/api/private/registries/"+registryID, req, nil)
4848
}
4949

5050
// DeleteRegistry deletes a registry resource by its ID.
51-
func (c Client) DeleteRegistry(ctx context.Context, orgID, registryID string) error {
52-
return c.requestBody(ctx, http.MethodDelete, "/api/private/orgs/"+orgID+"/registries/"+registryID, nil, nil)
51+
func (c Client) DeleteRegistry(ctx context.Context, registryID string) error {
52+
return c.requestBody(ctx, http.MethodDelete, "/api/private/registries/"+registryID, nil, nil)
53+
}
54+
55+
// CreateRegistryReq defines the request parameters for creating a new registry resource.
56+
type CreateRegistryReq struct {
57+
FriendlyName string `json:"friendly_name"`
58+
Registry string `json:"registry"`
59+
Username string `json:"username"`
60+
Password string `json:"password"`
61+
}
62+
63+
// CreateRegistry creates a new registry resource in an organization.
64+
func (c Client) CreateRegistry(ctx context.Context, orgID string, req CreateRegistryReq) (*Registry, error) {
65+
var r Registry
66+
if err := c.requestBody(ctx, http.MethodPost, "/api/private/orgs/"+orgID+"/registries", req, &r); err != nil {
67+
return nil, err
68+
}
69+
return &r, nil
5370
}

internal/cmd/tokens.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func regenTokenCmd() *cobra.Command {
106106
}
107107
token, err := client.RegenerateAPIToken(ctx, coder.Me, args[0])
108108
if err != nil {
109-
return nil
109+
return err
110110
}
111111
fmt.Println(token)
112112
return nil

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy