| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- package client
- import (
- "context"
- "fmt"
- "github.com/porter-dev/porter/api/types"
- )
- func (c *Client) NewGetPorterApp(
- ctx context.Context,
- projectID, clusterID uint,
- appName string,
- ) (*types.PorterApp, error) {
- resp := &types.PorterApp{}
- err := c.getRequest(
- fmt.Sprintf(
- "/projects/%d/clusters/%d/applications/%s",
- projectID, clusterID, appName,
- ),
- nil,
- resp,
- )
- return resp, err
- }
- func (c *Client) NewCreatePorterApp(
- ctx context.Context,
- projectID, clusterID uint,
- appName string,
- req *types.CreatePorterAppRequest,
- ) (*types.PorterApp, error) {
- resp := &types.PorterApp{}
- err := c.postRequest(
- fmt.Sprintf(
- "/projects/%d/clusters/%d/applications/%s",
- projectID, clusterID, appName,
- ),
- req,
- resp,
- )
- return resp, err
- }
- // NewCreateOrUpdatePorterAppEvent will create a porter app event if one does not exist, or else it will update the existing one if an ID is passed in the object
- func (c *Client) NewCreateOrUpdatePorterAppEvent(
- ctx context.Context,
- projectID, clusterID uint,
- appName string,
- req *types.CreateOrUpdatePorterAppEventRequest,
- ) (types.PorterAppEvent, error) {
- resp := &types.PorterAppEvent{}
- err := c.postRequest(
- fmt.Sprintf(
- "/projects/%d/clusters/%d/applications/%s/events",
- projectID, clusterID, appName,
- ),
- req,
- resp,
- )
- return *resp, err
- }
- // TODO: remove these functions once they are no longer called (check telemetry)
- func (c *Client) GetPorterApp(
- ctx context.Context,
- projectID, clusterID uint,
- stackName string,
- ) (*types.PorterApp, error) {
- resp := &types.PorterApp{}
- err := c.getRequest(
- fmt.Sprintf(
- "/projects/%d/clusters/%d/stacks/%s",
- projectID, clusterID, stackName,
- ),
- nil,
- resp,
- )
- return resp, err
- }
- func (c *Client) CreatePorterApp(
- ctx context.Context,
- projectID, clusterID uint,
- name string,
- req *types.CreatePorterAppRequest,
- ) (*types.PorterApp, error) {
- resp := &types.PorterApp{}
- err := c.postRequest(
- fmt.Sprintf(
- "/projects/%d/clusters/%d/stacks/%s",
- projectID, clusterID, name,
- ),
- req,
- resp,
- )
- return resp, err
- }
- // CreateOrUpdatePorterAppEvent will create a porter app event if one does not exist, or else it will update the existing one if an ID is passed in the object
- func (c *Client) CreateOrUpdatePorterAppEvent(
- ctx context.Context,
- projectID, clusterID uint,
- name string,
- req *types.CreateOrUpdatePorterAppEventRequest,
- ) (types.PorterAppEvent, error) {
- resp := &types.PorterAppEvent{}
- err := c.postRequest(
- fmt.Sprintf(
- "/projects/%d/clusters/%d/stacks/%s/events",
- projectID, clusterID, name,
- ),
- req,
- resp,
- )
- return *resp, err
- }
- // ListEnvGroups (List all Env Groups for a given cluster)
- func (c *Client) ListEnvGroups(
- ctx context.Context,
- projectID, clusterID uint,
- ) (types.ListEnvironmentGroupsResponse, error) {
- resp := &types.ListEnvironmentGroupsResponse{}
- err := c.getRequest(
- fmt.Sprintf(
- "/projects/%d/clusters/%d/environment-groups",
- projectID, clusterID,
- ),
- nil,
- resp,
- )
- return *resp, err
- }
|