github.com/scaleway/scaleway-cli@v1.11.1/pkg/pricing/pricing.go (about) 1 package pricing 2 3 import ( 4 "math/big" 5 "time" 6 ) 7 8 // Object represents a Pricing item definition 9 type Object struct { 10 Path string 11 Identifier string 12 Currency string 13 UsageUnit string 14 UnitPrice *big.Rat 15 UnitQuantity *big.Rat 16 UnitPriceCap *big.Rat 17 UsageGranularity time.Duration 18 } 19 20 // List represents a list of Object 21 type List []Object 22 23 // CurrentPricing tries to be up-to-date with the real pricing 24 // we cannot guarantee of these values since we hardcode values for now 25 // later, we should be able to call a dedicated pricing API 26 var CurrentPricing List 27 28 func init() { 29 CurrentPricing = List{ 30 { 31 Path: "/compute/c1/run", 32 Identifier: "aaaaaaaa-aaaa-4aaa-8aaa-111111111112", 33 Currency: "EUR", 34 UnitPrice: big.NewRat(2, 1000), // 0.002 35 UnitQuantity: big.NewRat(60000, 1000), // 60 36 UnitPriceCap: big.NewRat(1000, 1000), // 1 37 UsageGranularity: time.Minute, 38 }, 39 { 40 Path: "/compute/c2s/run", 41 Identifier: "aaaaaaaa-aaaa-4aaa-8aaa-222222222222", 42 Currency: "EUR", 43 UnitPrice: big.NewRat(20, 1000), // 0.02 44 UnitQuantity: big.NewRat(60000, 1000), // 60 45 UnitPriceCap: big.NewRat(10000, 1000), // 10 46 UsageGranularity: time.Minute, 47 }, 48 { 49 Path: "/compute/c2m/run", 50 Identifier: "aaaaaaaa-aaaa-4aaa-8aaa-444444444444", 51 Currency: "EUR", 52 UnitPrice: big.NewRat(32, 1000), // 0.032 53 UnitQuantity: big.NewRat(60000, 1000), // 60 54 UnitPriceCap: big.NewRat(16000, 1000), // 16 55 UsageGranularity: time.Minute, 56 }, 57 { 58 Path: "/compute/c2l/run", 59 Identifier: "aaaaaaaa-aaaa-4aaa-8aaa-333333333333", 60 Currency: "EUR", 61 UnitPrice: big.NewRat(44, 1000), // 0.044 62 UnitQuantity: big.NewRat(60000, 1000), // 60 63 UnitPriceCap: big.NewRat(22000, 1000), // 22 64 UsageGranularity: time.Minute, 65 }, 66 { 67 Path: "/compute/vc1s/run", 68 Identifier: "cccccccc-6ab1-4131-a35e-000000000001", 69 Currency: "EUR", 70 UnitPrice: big.NewRat(2, 1000), // 0.002 71 UnitQuantity: big.NewRat(60000, 1000), // 60 72 UnitPriceCap: big.NewRat(1000, 1000), // 1 73 UsageGranularity: time.Minute, 74 }, 75 { 76 Path: "/compute/vc1m/run", 77 Identifier: "cccccccc-6ab1-4131-a35e-000000000002", 78 Currency: "EUR", 79 UnitPrice: big.NewRat(6, 1000), // 0.006 80 UnitQuantity: big.NewRat(60000, 1000), // 60 81 UnitPriceCap: big.NewRat(3000, 1000), // 3 82 UsageGranularity: time.Minute, 83 }, 84 { 85 Path: "/compute/vc1l/run", 86 Identifier: "cccccccc-6ab1-4131-a35e-000000000003", 87 Currency: "EUR", 88 UnitPrice: big.NewRat(10, 1000), // 0.01 89 UnitQuantity: big.NewRat(60000, 1000), // 60 90 UnitPriceCap: big.NewRat(5000, 1000), // 5 91 UsageGranularity: time.Minute, 92 }, 93 { 94 Path: "/ip/dynamic", 95 Identifier: "467116bf-4631-49fb-905b-e07701c21111", 96 Currency: "EUR", 97 UnitPrice: big.NewRat(2, 1000), // 0.002 98 UnitQuantity: big.NewRat(60000, 1000), // 60 99 UnitPriceCap: big.NewRat(990, 1000), // 0.99 100 UsageGranularity: time.Minute, 101 }, 102 { 103 Path: "/ip/reserved", 104 Identifier: "467116bf-4631-49fb-905b-e07701c22222", 105 Currency: "EUR", 106 UnitPrice: big.NewRat(2, 1000), // 0.002 107 UnitQuantity: big.NewRat(60000, 1000), // 60 108 UnitPriceCap: big.NewRat(990, 1000), // 0.99 109 UsageGranularity: time.Minute, 110 }, 111 { 112 Path: "/storage/local/ssd/storage", 113 Identifier: "bbbbbbbb-bbbb-4bbb-8bbb-111111111144", 114 Currency: "EUR", 115 UnitPrice: big.NewRat(2, 1000), // 0.002 116 UnitQuantity: big.NewRat(50000, 1000), // 50 117 UnitPriceCap: big.NewRat(1000, 1000), // 1 118 UsageGranularity: time.Hour, 119 }, 120 } 121 } 122 123 // GetByPath returns an object matching a path 124 func (pl *List) GetByPath(path string) *Object { 125 for _, object := range *pl { 126 if object.Path == path { 127 return &object 128 } 129 } 130 return nil 131 } 132 133 // GetByIdentifier returns an object matching a identifier 134 func (pl *List) GetByIdentifier(identifier string) *Object { 135 for _, object := range *pl { 136 if object.Identifier == identifier { 137 return &object 138 } 139 } 140 return nil 141 }