plan.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package models
  2. type Plan struct {
  3. ID string `json:"id"`
  4. Name string `json:"name"`
  5. Description string `json:"description"`
  6. Price int64 `json:"price"`
  7. Currency string `json:"currency"`
  8. Specs VMSpecs `json:"specs"`
  9. }
  10. type VMSpecs struct {
  11. CPU int `json:"cpu"`
  12. RAM int `json:"ram_gb"` // RAM in GB
  13. Storage int `json:"storage_gb"` // Storage in GB
  14. Region string `json:"region"`
  15. }
  16. const (
  17. PlanBasic = "basic"
  18. PlanPro = "pro"
  19. PlanEnterprise = "enterprise"
  20. )
  21. var DefaultPlans = map[string]*Plan{
  22. PlanBasic: {
  23. ID: PlanBasic,
  24. Name: "Basic",
  25. Description: "Perfect for starting projects",
  26. Price: 999, // 9.99 EUR
  27. Currency: "EUR",
  28. Specs: VMSpecs{
  29. CPU: 1,
  30. RAM: 2,
  31. Storage: 40,
  32. },
  33. },
  34. PlanPro: {
  35. ID: PlanPro,
  36. Name: "Professional",
  37. Price: 2999, // 29.99 EUR
  38. Currency: "EUR",
  39. Specs: VMSpecs{
  40. CPU: 2,
  41. RAM: 4,
  42. Storage: 80,
  43. },
  44. },
  45. PlanEnterprise: {
  46. ID: PlanEnterprise,
  47. Name: "Enterprise",
  48. Price: 9999, // 99.99 EUR
  49. Currency: "EUR",
  50. Specs: VMSpecs{
  51. CPU: 4,
  52. RAM: 16,
  53. Storage: 160,
  54. },
  55. },
  56. }
  57. func GetPlan(planID string) (*Plan, bool) {
  58. plan, exists := DefaultPlans[planID]
  59. return plan, exists
  60. }