2
0

v1_stack.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package client
  2. import (
  3. "context"
  4. "fmt"
  5. "github.com/porter-dev/porter/api/types"
  6. )
  7. // ListStacks retrieves the list of stacks
  8. func (c *Client) ListStacks(
  9. ctx context.Context,
  10. projectID, clusterID uint,
  11. namespace string,
  12. ) (*types.StackListResponse, error) {
  13. resp := &types.StackListResponse{}
  14. err := c.getRequest(
  15. fmt.Sprintf(
  16. "/v1/projects/%d/clusters/%d/namespaces/%s/stacks",
  17. projectID, clusterID, namespace,
  18. ),
  19. nil,
  20. resp,
  21. )
  22. return resp, err
  23. }
  24. func (c *Client) AddEnvGroupToStack(
  25. ctx context.Context,
  26. projectID, clusterID uint,
  27. namespace, stackID string,
  28. req *types.CreateStackEnvGroupRequest,
  29. ) error {
  30. err := c.patchRequest(
  31. fmt.Sprintf(
  32. "/v1/projects/%d/clusters/%d/namespaces/%s/stacks/%s/add_env_group",
  33. projectID, clusterID, namespace, stackID,
  34. ),
  35. req,
  36. nil,
  37. )
  38. return err
  39. }
  40. func (c *Client) RemoveEnvGroupFromStack(
  41. ctx context.Context,
  42. projectID, clusterID uint,
  43. namespace, stackID, envGroupName string,
  44. ) error {
  45. err := c.deleteRequest(
  46. fmt.Sprintf(
  47. "/v1/projects/%d/clusters/%d/namespaces/%s/stacks/%s/remove_env_group/%s",
  48. projectID, clusterID, namespace, stackID, envGroupName,
  49. ),
  50. nil,
  51. nil,
  52. )
  53. return err
  54. }