1 // Copyright 2022-2025 The sacloud/iaas-api-go 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 naked
16 17 import (
18 "encoding/json"
19 20 "github.com/sacloud/iaas-api-go/types"
21 )
22 23 // ServiceClass 料金
24 type ServiceClass struct {
25 ID types.ID `json:"ServiceClassID" yaml:"service_class_id"` // サービスクラスID
26 ServiceClassName string `yaml:"service_class_name"` // サービスクラス名
27 ServiceClassPath string `yaml:"service_class_path"` // サービスクラスパス
28 DisplayName string `yaml:"display_name"` // 表示名
29 IsPublic bool `yaml:"is_public"` // 公開フラグ
30 Price *Price `yaml:"price"`
31 }
32 33 // Price 価格
34 type Price struct {
35 Base int `yaml:"base"` // 基本料金
36 Daily int `yaml:"daily"` // 日単位料金
37 Hourly int `yaml:"hourly"` // 時間単位料金
38 Monthly int `yaml:"monthly"` // 分単位料金
39 PerUse int `yaml:"per_use"` // 自動バックアップ
40 Basic int `yaml:"basic"` // AWS接続オプション: 基本料
41 Traffic int `yaml:"traffic"` // AWS接続オプション: トラフィック課金
42 DocomoTraffic int `yaml:"docomo_traffic"` // セキュアモバイルコネクト: Docomo
43 KddiTraffic int `yaml:"kddi_traffic"` // セキュアモバイルコネクト: KDDI
44 SbTraffic int `yaml:"sb_traffic"` // セキュアモバイルコネクト: SoftBank
45 SimSheet int `yaml:"sim_sheet"` // SIM
46 Zone string `yaml:"zone"` // ゾーン
47 }
48 49 // UnmarshalJSON 配列/オブジェクトが混在することへの対応
50 func (p *Price) UnmarshalJSON(b []byte) error {
51 if string(b) == "[]" {
52 return nil
53 }
54 type alias Price
55 56 var a alias
57 if err := json.Unmarshal(b, &a); err != nil {
58 return err
59 }
60 *p = Price(a)
61 return nil
62 }
63