integration.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. package client
  2. import (
  3. "context"
  4. "fmt"
  5. "github.com/porter-dev/porter/api/types"
  6. )
  7. // CreateAWSIntegration creates an AWS integration with the given request options
  8. func (c *Client) CreateAWSIntegration(
  9. ctx context.Context,
  10. projectID uint,
  11. req *types.CreateAWSRequest,
  12. ) (*types.CreateAWSResponse, error) {
  13. resp := &types.CreateAWSResponse{}
  14. err := c.postRequest(
  15. fmt.Sprintf(
  16. "/projects/%d/integrations/aws",
  17. projectID,
  18. ),
  19. req,
  20. resp,
  21. )
  22. return resp, err
  23. }
  24. // CreateGCPIntegration creates a GCP integration with the given request options
  25. func (c *Client) CreateGCPIntegration(
  26. ctx context.Context,
  27. projectID uint,
  28. req *types.CreateGCPRequest,
  29. ) (*types.CreateGCPResponse, error) {
  30. resp := &types.CreateGCPResponse{}
  31. err := c.postRequest(
  32. fmt.Sprintf(
  33. "/projects/%d/integrations/gcp",
  34. projectID,
  35. ),
  36. req,
  37. resp,
  38. )
  39. return resp, err
  40. }
  41. // CreateBasicAuthIntegration creates a "basic auth" integration
  42. func (c *Client) CreateBasicAuthIntegration(
  43. ctx context.Context,
  44. projectID uint,
  45. req *types.CreateBasicRequest,
  46. ) (*types.CreateBasicResponse, error) {
  47. resp := &types.CreateBasicResponse{}
  48. err := c.postRequest(
  49. fmt.Sprintf(
  50. "/projects/%d/integrations/basic",
  51. projectID,
  52. ),
  53. req,
  54. resp,
  55. )
  56. return resp, err
  57. }
  58. // ListOAuthIntegrations lists the oauth integrations in a project
  59. func (c *Client) ListOAuthIntegrations(
  60. ctx context.Context,
  61. projectID uint,
  62. ) (*types.ListOAuthResponse, error) {
  63. resp := &types.ListOAuthResponse{}
  64. err := c.getRequest(
  65. fmt.Sprintf(
  66. "/projects/%d/integrations/oauth",
  67. projectID,
  68. ),
  69. nil,
  70. resp,
  71. )
  72. return resp, err
  73. }