project.go 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. package types
  2. // ProjectList type for entries in the api response on GET /projects
  3. type ProjectList struct {
  4. ID uint `json:"id"`
  5. Name string `json:"name"`
  6. // note: all of these fields should be considered deprecated
  7. // in an api response
  8. Roles []Role `json:"roles"`
  9. PreviewEnvsEnabled bool `json:"preview_envs_enabled"`
  10. RDSDatabasesEnabled bool `json:"enable_rds_databases"`
  11. ManagedInfraEnabled bool `json:"managed_infra_enabled"`
  12. APITokensEnabled bool `json:"api_tokens_enabled"`
  13. StacksEnabled bool `json:"stacks_enabled"`
  14. CapiProvisionerEnabled bool `json:"capi_provisioner_enabled"`
  15. BillingEnabled bool `json:"billing_enabled"`
  16. DBEnabled bool `json:"db_enabled"`
  17. SimplifiedViewEnabled bool `json:"simplified_view_enabled"`
  18. AzureEnabled bool `json:"azure_enabled"`
  19. HelmValuesEnabled bool `json:"helm_values_enabled"`
  20. MultiCluster bool `json:"multi_cluster"`
  21. FullAddOns bool `json:"full_add_ons"`
  22. EnableReprovision bool `json:"enable_reprovision"`
  23. ValidateApplyV2 bool `json:"validate_apply_v2"`
  24. AdvancedInfraEnabled bool `json:"advanced_infra_enabled"`
  25. SandboxEnabled bool `json:"sandbox_enabled"`
  26. AdvancedRbacEnabled bool `json:"advanced_rbac_enabled"`
  27. }
  28. // Project type for entries in api responses for everything other than `GET /projects`
  29. type Project struct {
  30. ID uint `json:"id"`
  31. Name string `json:"name"`
  32. Roles []*Role `json:"roles"`
  33. APITokensEnabled bool `json:"api_tokens_enabled"`
  34. AWSACKAuthEnabled bool `json:"aws_ack_auth_enabled"`
  35. AzureEnabled bool `json:"azure_enabled"`
  36. BetaFeaturesEnabled bool `json:"beta_features_enabled"`
  37. CapiProvisionerEnabled bool `json:"capi_provisioner_enabled"`
  38. BillingEnabled bool `json:"billing_enabled"`
  39. LagoEnabled bool `json:"metronome_enabled"`
  40. InfisicalEnabled bool `json:"infisical_enabled"`
  41. FreezeEnabled bool `json:"freeze_enabled"`
  42. DBEnabled bool `json:"db_enabled"`
  43. EFSEnabled bool `json:"efs_enabled"`
  44. EnableReprovision bool `json:"enable_reprovision"`
  45. FullAddOns bool `json:"full_add_ons"`
  46. GPUEnabled bool `json:"gpu_enabled"`
  47. HelmValuesEnabled bool `json:"helm_values_enabled"`
  48. ManagedInfraEnabled bool `json:"managed_infra_enabled"`
  49. MultiCluster bool `json:"multi_cluster"`
  50. PreviewEnvsEnabled bool `json:"preview_envs_enabled"`
  51. QuotaIncrease bool `json:"quota_increase"`
  52. RDSDatabasesEnabled bool `json:"enable_rds_databases"`
  53. SimplifiedViewEnabled bool `json:"simplified_view_enabled"`
  54. SOC2ControlsEnabled bool `json:"soc2_controls_enabled"`
  55. StacksEnabled bool `json:"stacks_enabled"`
  56. ValidateApplyV2 bool `json:"validate_apply_v2"`
  57. ManagedDeploymentTargetsEnabled bool `json:"managed_deployment_targets_enabled"`
  58. AdvancedInfraEnabled bool `json:"advanced_infra_enabled"`
  59. SandboxEnabled bool `json:"sandbox_enabled"`
  60. AdvancedRbacEnabled bool `json:"advanced_rbac_enabled"`
  61. // ReferralCode is a unique code that can be shared to referr other users to Porter
  62. ReferralCode string `json:"referral_code"`
  63. }
  64. // FeatureFlags is a struct that contains old feature flag representations
  65. //
  66. // Deprecated: Add the feature flag to the `Project` struct instead and
  67. // retrieve feature flags from the `GET /projects/{project_id}` response instead
  68. type FeatureFlags struct {
  69. AzureEnabled bool `json:"azure_enabled,omitempty"`
  70. BillingEnabled bool `json:"billing_enabled,omitempty"`
  71. CapiProvisionerEnabled string `json:"capi_provisioner_enabled,omitempty"`
  72. EnableReprovision bool `json:"enable_reprovision,omitempty"`
  73. FullAddOns bool `json:"full_add_ons,omitempty"`
  74. HelmValuesEnabled bool `json:"helm_values_enabled,omitempty"`
  75. ManagedDatabasesEnabled string `json:"managed_databases_enabled,omitempty"`
  76. ManagedInfraEnabled string `json:"managed_infra_enabled,omitempty"`
  77. MultiCluster bool `json:"multi_cluster,omitempty"`
  78. PreviewEnvironmentsEnabled string `json:"preview_environments_enabled,omitempty"`
  79. SimplifiedViewEnabled string `json:"simplified_view_enabled,omitempty"`
  80. StacksEnabled string `json:"stacks_enabled,omitempty"`
  81. ValidateApplyV2 bool `json:"validate_apply_v2"`
  82. ManagedDeploymentTargetsEnabled bool `json:"managed_deployment_targets_enabled"`
  83. AdvancedRbacEnabled bool `json:"advanced_rbac_enabled"`
  84. }
  85. // CreateProjectRequest is a struct that contains the information
  86. // necessary to seed a project
  87. type CreateProjectRequest struct {
  88. Name string `json:"name" form:"required"`
  89. }
  90. // CreateProjectResponse is a struct that contains the response from a create project call
  91. type CreateProjectResponse Project
  92. // CreateProjectRoleRequest is a struct that contains the information needed to set a role on a user
  93. type CreateProjectRoleRequest struct {
  94. Kind string `json:"kind" form:"required"`
  95. UserID uint `json:"user_id" form:"required"`
  96. }
  97. // ProjectInviteAdminRequest is a struct that contains the information needed to invite an admin to a project
  98. type ProjectInviteAdminRequest struct{}
  99. // ReadProjectResponse is a struct that contains the response from a `GET /projects/{project_id}` request
  100. type ReadProjectResponse Project
  101. // ListProjectsRequest is a struct that contains the information needed to make a `GET /projects` request
  102. type ListProjectsRequest struct{}
  103. // ListProjectsResponse is a struct that contains the response from a `GET /projects` request
  104. type ListProjectsResponse []Project
  105. // DeleteProjectRequest is a struct that contains the information needed to make a `DELETE /projects` request
  106. type DeleteProjectRequest struct {
  107. Name string `json:"name" form:"required"`
  108. }
  109. // DeleteProjectResponse is a struct that contains the response from a `DELETE /projects` request
  110. type DeleteProjectResponse Project
  111. // ListProjectInfraResponse is a struct that contains the response from a `GET projects/{project_id}/infra` request
  112. type ListProjectInfraResponse []*Infra
  113. // GetProjectPolicyResponse is a struct that contains the response from a `GET projects/{project_id}/policy` request
  114. type GetProjectPolicyResponse []*PolicyDocument
  115. // ListProjectRolesResponse is a struct that contains the response from a `GET projects/{project_id}/roles` request
  116. type ListProjectRolesResponse []RoleKind
  117. // Collaborator is a struct defining a collaborator on a project
  118. type Collaborator struct {
  119. ID uint `json:"id"`
  120. Kind string `json:"kind"`
  121. UserID uint `json:"user_id"`
  122. Email string `json:"email"`
  123. ProjectID uint `json:"project_id"`
  124. }
  125. // ListCollaboratorsResponse is a struct that contains the response from a `GET projects/{project_id}/collaborators` request
  126. type ListCollaboratorsResponse []*Collaborator
  127. // UpdateRoleRequest is a struct that contains the information needed to make a `POST projects/{project_id}/roles` request
  128. type UpdateRoleRequest struct {
  129. UserID uint `json:"user_id,required"`
  130. Kind string `json:"kind,required"`
  131. }
  132. // UpdateRoleResponse is a struct that contains the response from a `POST projects/{project_id}/roles` request
  133. type UpdateRoleResponse struct {
  134. *Role
  135. }
  136. // DeleteRoleRequest is a struct that contains the response from a `DELETE projects/{project_id}/roles` request
  137. type DeleteRoleRequest struct {
  138. UserID uint `schema:"user_id,required"`
  139. }
  140. // DeleteRoleResponse is a struct that contains the response from a `DELETE projects/{project_id}/roles` request
  141. type DeleteRoleResponse struct {
  142. *Role
  143. }
  144. // GetProjectBillingResponse is a struct that contains the response from a `GET projects/{project_id}/billing` request
  145. type GetProjectBillingResponse struct {
  146. HasBilling bool `json:"has_billing"`
  147. }
  148. // StepEnum is a type describing the current onboarding step
  149. type StepEnum string
  150. const (
  151. // StepConnectSource is a value describing the current onboarding step as `connect_source` (the first step)
  152. StepConnectSource StepEnum = "connect_source"
  153. // StepCleanUp is a value describing the current onboarding step as `clean_up` (the last step)
  154. StepCleanUp StepEnum = "clean_up"
  155. )
  156. // ConnectedSourceType describes the source of an onboarding
  157. type ConnectedSourceType string
  158. const (
  159. // ConnectedSourceTypeGithub is the github source
  160. ConnectedSourceTypeGithub = "github"
  161. // ConnectedSourceTypeDocker is the docker source
  162. ConnectedSourceTypeDocker = "docker"
  163. )
  164. // OnboardingData is an onboarding step
  165. type OnboardingData struct {
  166. CurrentStep StepEnum `json:"current_step"`
  167. ConnectedSource ConnectedSourceType `json:"connected_source"`
  168. SkipRegistryConnection bool `json:"skip_registry_connection"`
  169. SkipResourceProvision bool `json:"skip_resource_provision"`
  170. RegistryConnectionID uint `json:"registry_connection_id"`
  171. RegistryConnectionCredentialID uint `json:"registry_connection_credential_id"`
  172. RegistryConnectionProvider string `json:"registry_connection_provider"`
  173. RegistryInfraID uint `json:"registry_infra_id"`
  174. RegistryInfraCredentialID uint `json:"registry_infra_credential_id"`
  175. RegistryInfraProvider string `json:"registry_infra_provider"`
  176. ClusterInfraID uint `json:"cluster_infra_id"`
  177. ClusterInfraCredentialID uint `json:"cluster_infra_credential_id"`
  178. ClusterInfraProvider string `json:"cluster_infra_provider"`
  179. }
  180. // UpdateOnboardingRequest is a struct that contains the information needed to make a `POST projects/{project_id}/onboarding` request
  181. type UpdateOnboardingRequest OnboardingData
  182. // UpdateOnboardingStepRequest is a struct that contains the information needed to make a `POST projects/{project_id}/onboarding_step` request
  183. type UpdateOnboardingStepRequest struct {
  184. Step string `json:"step" form:"required,max=255"`
  185. Provider string `json:"provider"`
  186. CloudProviderCredentialIdentifier string `json:"cloud_provider_credential_identifier"`
  187. AccountId string `json:"account_id"`
  188. CloudformationURL string `json:"cloudformation_url"`
  189. ErrorMessage string `json:"error_message"`
  190. LoginURL string `json:"login_url"`
  191. Region string `json:"region"`
  192. ClusterName string `json:"cluster_name"`
  193. // ExternalId used as a 'password' for the aws assume role chain to porter-manager role
  194. ExternalId string `json:"external_id"`
  195. }
  196. // UpdateProjectNameRequest takes in a name to rename projects
  197. type UpdateProjectNameRequest struct {
  198. Name string `json:"name" form:"required"`
  199. }