github.com/sacloud/libsacloud/v2@v2.32.3/internal/define/service_class.go (about) 1 // Copyright 2016-2022 The Libsacloud Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package define 16 17 import ( 18 "github.com/sacloud/libsacloud/v2/internal/define/ops" 19 "github.com/sacloud/libsacloud/v2/internal/dsl" 20 "github.com/sacloud/libsacloud/v2/internal/dsl/meta" 21 "github.com/sacloud/libsacloud/v2/sacloud/naked" 22 ) 23 24 const ( 25 serviceClassAPIName = "ServiceClass" 26 serviceClassAPIPathName = "public/price" 27 ) 28 29 var serviceClassAPI = &dsl.Resource{ 30 Name: serviceClassAPIName, 31 PathName: serviceClassAPIPathName, 32 PathSuffix: dsl.CloudAPISuffix, 33 Operations: dsl.Operations{ 34 ops.Find(serviceClassAPIName, serviceClassNakedType, findParameter, serviceClassView), 35 }, 36 } 37 38 var ( 39 serviceClassNakedType = meta.Static(naked.ServiceClass{}) 40 serviceClassView = &dsl.Model{ 41 Name: serviceClassAPIName, 42 NakedType: serviceClassNakedType, 43 Fields: []*dsl.FieldDesc{ 44 fields.ID(), 45 fields.Def("ServiceClassName", meta.TypeString), 46 fields.Def("ServiceClassPath", meta.TypeString), 47 fields.Def("DisplayName", meta.TypeString), 48 fields.Def("IsPublic", meta.TypeFlag), 49 { 50 Name: "Price", 51 Type: priceModel, 52 Tags: &dsl.FieldTags{ 53 MapConv: ",recursive", 54 }, 55 }, 56 }, 57 } 58 59 priceModel = &dsl.Model{ 60 Name: "Price", 61 NakedType: meta.Static(naked.Price{}), 62 Fields: []*dsl.FieldDesc{ 63 fields.Def("Base", meta.TypeInt), 64 fields.Def("Daily", meta.TypeInt), 65 fields.Def("Hourly", meta.TypeInt), 66 fields.Def("Monthly", meta.TypeInt), 67 fields.Def("PerUse", meta.TypeInt), 68 fields.Def("Basic", meta.TypeInt), 69 fields.Def("Traffic", meta.TypeInt), 70 fields.Def("DocomoTraffic", meta.TypeInt), 71 fields.Def("KddiTraffic", meta.TypeInt), 72 fields.Def("SbTraffic", meta.TypeInt), 73 fields.Def("SimSheet", meta.TypeInt), 74 fields.Def("Zone", meta.TypeString), 75 }, 76 } 77 )