project.go 11 KB

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