yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/cloudprovider/subaccount.go (about)

     1  // Copyright 2019 Yunion
     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 cloudprovider
    16  
    17  import (
    18  	"reflect"
    19  
    20  	"yunion.io/x/jsonutils"
    21  	"yunion.io/x/pkg/gotypes"
    22  )
    23  
    24  type SSubAccount struct {
    25  	// 若Account不为空,可不传
    26  	Name string
    27  	// 描述信息
    28  	Desc string
    29  	// 输入必填,若为空,需要指定子账号名称
    30  	Account          string
    31  	HealthStatus     string // 云端服务健康状态。例如欠费、项目冻结都属于不健康状态。
    32  	DefaultProjectId string // 默认云订阅项目Id
    33  }
    34  
    35  // +onecloud:model-api-gen
    36  type SubAccounts struct {
    37  	// 若输出则是全量子账号列表,若输入,代表允许同步的子账号
    38  	Accounts []SSubAccount
    39  	// 若输出是云账号查询到的区域列表,若输入,代表允许同步的区域
    40  	Cloudregions []struct {
    41  		// 输入必填
    42  		Id     string
    43  		Name   string
    44  		Status string
    45  	}
    46  }
    47  
    48  func (self SubAccounts) IsZero() bool {
    49  	return len(self.Accounts) == 0
    50  }
    51  
    52  func (self SubAccounts) String() string {
    53  	return jsonutils.Marshal(self).String()
    54  }
    55  
    56  func init() {
    57  	gotypes.RegisterSerializable(reflect.TypeOf(&SubAccounts{}), func() gotypes.ISerializable {
    58  		return &SubAccounts{}
    59  	})
    60  }