|
| 1 | +package coder |
| 2 | + |
| 3 | +import ( |
| 4 | +"context" |
| 5 | +"net/http" |
| 6 | +) |
| 7 | + |
| 8 | +// ResourcePool defines an entity capable of deploying and acting as an ingress for Coder environments. |
| 9 | +typeResourcePoolstruct { |
| 10 | +IDstring`json:"id"` |
| 11 | +Namestring`json:"name"` |
| 12 | +Localbool`json:"local"` |
| 13 | +ClusterAddressstring`json:"cluster_address"` |
| 14 | +DefaultNamespacestring`json:"default_namespace"` |
| 15 | +StorageClassstring`json:"storage_class"` |
| 16 | +ClusterDomainSuffixstring`json:"cluster_domain_suffix"` |
| 17 | +DevurlHoststring`json:"devurl_host"` |
| 18 | +NamespaceWhitelist []string`json:"namespace_whitelist"` |
| 19 | +OrgWhitelist []string`json:"org_whitelist"` |
| 20 | +} |
| 21 | + |
| 22 | +// ResourcePoolByID fetches a resource pool entity by its unique ID. |
| 23 | +func (c*Client)ResourcePoolByID(ctx context.Context,idstring) (*ResourcePool,error) { |
| 24 | +varrpResourcePool |
| 25 | +iferr:=c.requestBody(ctx,http.MethodGet,"/api/private/resource-pools/"+id,nil,&rp);err!=nil { |
| 26 | +returnnil,err |
| 27 | +} |
| 28 | +return&rp,nil |
| 29 | +} |
| 30 | + |
| 31 | +// DeleteResourcePoolByID deletes a resource pool entity from the Coder control plane. |
| 32 | +func (c*Client)DeleteResourcePoolByID(ctx context.Context,idstring)error { |
| 33 | +returnc.requestBody(ctx,http.MethodDelete,"/api/private/resource-pools/"+id,nil,nil) |
| 34 | +} |
| 35 | + |
| 36 | +// ResourcePools fetches all resource pools known to the Coder control plane. |
| 37 | +func (c*Client)ResourcePools(ctx context.Context) ([]ResourcePool,error) { |
| 38 | +varpools []ResourcePool |
| 39 | +iferr:=c.requestBody(ctx,http.MethodGet,"/api/private/resource-pools",nil,&pools);err!=nil { |
| 40 | +returnnil,err |
| 41 | +} |
| 42 | +returnpools,nil |
| 43 | +} |
| 44 | + |
| 45 | +// CreateResourcePoolReq defines the request parameters for creating a new resource pool entity. |
| 46 | +typeCreateResourcePoolReqstruct { |
| 47 | +Namestring`json:"name"` |
| 48 | +Localbool`json:"local"` |
| 49 | +ClusterCAstring`json:"cluster_ca"` |
| 50 | +ClusterAddressstring`json:"cluster_address"` |
| 51 | +SATokenstring`json:"sa_token"` |
| 52 | +DefaultNamespacestring`json:"default_namespace"` |
| 53 | +StorageClassstring`json:"storage_class"` |
| 54 | +ClusterDomainSuffixstring`json:"cluster_domain_suffix"` |
| 55 | +DevurlHoststring`json:"devurl_host"` |
| 56 | +NamespaceWhitelist []string`json:"namespace_whitelist"` |
| 57 | +OrgWhitelist []string`json:"org_whitelist"` |
| 58 | +} |
| 59 | + |
| 60 | +// CreateResourcePool creates a new ResourcePool entity. |
| 61 | +func (c*Client)CreateResourcePool(ctx context.Context,reqCreateResourcePoolReq)error { |
| 62 | +returnc.requestBody(ctx,http.MethodPost,"/api/private/resource-pools",req,nil) |
| 63 | +} |