Browse Source

add client implementation for deployment endpoints

Alexander Belanger 4 years ago
parent
commit
7f8a65ce6b
1 changed files with 46 additions and 0 deletions
  1. 46 0
      api/client/environment.go

+ 46 - 0
api/client/environment.go

@@ -0,0 +1,46 @@
+package client
+
+import (
+	"context"
+	"fmt"
+
+	"github.com/porter-dev/porter/api/types"
+)
+
+func (c *Client) CreateDeployment(
+	ctx context.Context,
+	projID, gitInstallationID, clusterID uint,
+	req *types.CreateDeploymentRequest,
+) (*types.Deployment, error) {
+	resp := &types.Deployment{}
+
+	err := c.postRequest(
+		fmt.Sprintf(
+			"/projects/%d/gitrepos/%d/clusters/%d/deployment",
+			projID, gitInstallationID, clusterID,
+		),
+		req,
+		resp,
+	)
+
+	return resp, err
+}
+
+func (c *Client) FinalizeDeployment(
+	ctx context.Context,
+	projID, gitInstallationID, clusterID uint,
+	req *types.FinalizeDeploymentRequest,
+) (*types.Deployment, error) {
+	resp := &types.Deployment{}
+
+	err := c.postRequest(
+		fmt.Sprintf(
+			"/projects/%d/gitrepos/%d/clusters/%d/deployment/finalize",
+			projID, gitInstallationID, clusterID,
+		),
+		req,
+		resp,
+	)
+
+	return resp, err
+}