Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions coder-sdk/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Environment struct {
AutoOffThreshold Duration `json:"auto_off_threshold" table:"-"`
SSHAvailable bool `json:"ssh_available" table:"-"`
UseContainerVM bool `json:"use_container_vm" table:"CVM"`
ResourcePoolID string `json:"resource_pool_id" table:"-"`
}

// RebuildMessage defines the message shown when an Environment requires a rebuild for it can be accessed.
Expand Down
63 changes: 63 additions & 0 deletions coder-sdk/resourcepools.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package coder

import (
"context"
"net/http"
)

// ResourcePool defines an entity capable of deploying and acting as an ingress for Coder environments.
type ResourcePool struct {
ID string `json:"id"`
Name string `json:"name"`
Local bool `json:"local"`
ClusterAddress string `json:"cluster_address"`
DefaultNamespace string `json:"default_namespace"`
StorageClass string `json:"storage_class"`
ClusterDomainSuffix string `json:"cluster_domain_suffix"`
DevurlHost string `json:"devurl_host"`
NamespaceWhitelist []string `json:"namespace_whitelist"`
OrgWhitelist []string `json:"org_whitelist"`
}

// ResourcePoolByID fetches a resource pool entity by its unique ID.
func (c *Client) ResourcePoolByID(ctx context.Context, id string) (*ResourcePool, error) {
var rp ResourcePool
if err := c.requestBody(ctx, http.MethodGet, "/api/private/resource-pools/"+id, nil, &rp); err != nil {
return nil, err
}
return &rp, nil
}

// DeleteResourcePoolByID deletes a resource pool entity from the Coder control plane.
func (c *Client) DeleteResourcePoolByID(ctx context.Context, id string) error {
return c.requestBody(ctx, http.MethodDelete, "/api/private/resource-pools/"+id, nil, nil)
}

// ResourcePools fetches all resource pools known to the Coder control plane.
func (c *Client) ResourcePools(ctx context.Context) ([]ResourcePool, error) {
var pools []ResourcePool
if err := c.requestBody(ctx, http.MethodGet, "/api/private/resource-pools", nil, &pools); err != nil {
return nil, err
}
return pools, nil
}

// CreateResourcePoolReq defines the request parameters for creating a new resource pool entity.
type CreateResourcePoolReq struct {
Name string `json:"name"`
Local bool `json:"local"`
ClusterCA string `json:"cluster_ca"`
ClusterAddress string `json:"cluster_address"`
SAToken string `json:"sa_token"`
DefaultNamespace string `json:"default_namespace"`
StorageClass string `json:"storage_class"`
ClusterDomainSuffix string `json:"cluster_domain_suffix"`
DevurlHost string `json:"devurl_host"`
NamespaceWhitelist []string `json:"namespace_whitelist"`
OrgWhitelist []string `json:"org_whitelist"`
}

// CreateResourcePool creates a new ResourcePool entity.
func (c *Client) CreateResourcePool(ctx context.Context, req CreateResourcePoolReq) error {
return c.requestBody(ctx, http.MethodPost, "/api/private/resource-pools", req, nil)
}
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