github.com/sacloud/iaas-api-go@v1.12.0/types/proxylb_plan.go (about)

     1  // Copyright 2022-2023 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 types
    16  
    17  import (
    18  	"fmt"
    19  	"strings"
    20  )
    21  
    22  // EProxyLBPlan エンハンスドロードバランサのプラン
    23  //
    24  // エンハンスドロードバランサではプランはIDを受け取る形(Plan.ID)ではなく、
    25  // ServiceClassに"cloud/proxylb/plain/100"のような形で文字列で指定する。
    26  // このままでは扱いにくいためEProxyLBPlan型を設け、この型でjson.Marshaler/Unmarshalerを実装し
    27  // プラン名とServiceClassでの文字列表現とで相互変換可能とする。
    28  type EProxyLBPlan int
    29  
    30  // Int EProxyLBPlanのint表現
    31  func (p EProxyLBPlan) Int() int {
    32  	return int(p)
    33  }
    34  
    35  // String EProxyLBPlanの文字列表現
    36  func (p EProxyLBPlan) String() string {
    37  	return fmt.Sprintf("%d", p)
    38  }
    39  
    40  // ProxyLBPlans エンハンスドロードバランサのプラン
    41  var ProxyLBPlans = struct {
    42  	CPS100    EProxyLBPlan
    43  	CPS500    EProxyLBPlan
    44  	CPS1000   EProxyLBPlan
    45  	CPS5000   EProxyLBPlan
    46  	CPS10000  EProxyLBPlan
    47  	CPS50000  EProxyLBPlan
    48  	CPS100000 EProxyLBPlan
    49  	CPS400000 EProxyLBPlan
    50  }{
    51  	CPS100:    EProxyLBPlan(100),
    52  	CPS500:    EProxyLBPlan(500),
    53  	CPS1000:   EProxyLBPlan(1_000),
    54  	CPS5000:   EProxyLBPlan(5_000),
    55  	CPS10000:  EProxyLBPlan(10_000),
    56  	CPS50000:  EProxyLBPlan(50_000),
    57  	CPS100000: EProxyLBPlan(100_000),
    58  	CPS400000: EProxyLBPlan(400_000),
    59  }
    60  
    61  // ProxyLBPlanValues 有効なプランを表すint値
    62  var ProxyLBPlanValues = []int{
    63  	int(ProxyLBPlans.CPS100),
    64  	int(ProxyLBPlans.CPS500),
    65  	int(ProxyLBPlans.CPS1000),
    66  	int(ProxyLBPlans.CPS5000),
    67  	int(ProxyLBPlans.CPS10000),
    68  	int(ProxyLBPlans.CPS50000),
    69  	int(ProxyLBPlans.CPS100000),
    70  	int(ProxyLBPlans.CPS400000),
    71  }
    72  
    73  // ProxyLBPlanString 有効なプランを表す文字列(スペース区切り)
    74  var ProxyLBPlanString = strings.Join([]string{
    75  	ProxyLBPlans.CPS100.String(),
    76  	ProxyLBPlans.CPS500.String(),
    77  	ProxyLBPlans.CPS1000.String(),
    78  	ProxyLBPlans.CPS5000.String(),
    79  	ProxyLBPlans.CPS10000.String(),
    80  	ProxyLBPlans.CPS50000.String(),
    81  	ProxyLBPlans.CPS100000.String(),
    82  	ProxyLBPlans.CPS400000.String(),
    83  }, " ")