project.go 11 KB

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