subaccount.go 1.7 KB

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