project.go 10 KB

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