project.go 9.4 KB

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