project.go 10.0 KB

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