project.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 identity
  15. import (
  16. "yunion.io/x/jsonutils"
  17. "yunion.io/x/pkg/errors"
  18. api "yunion.io/x/onecloud/pkg/apis/identity"
  19. "yunion.io/x/onecloud/pkg/mcclient/options"
  20. )
  21. type ProjectListOptions struct {
  22. options.BaseListOptions
  23. UserId string `help:"filter by user id"`
  24. GroupId string `help:"filter by group id"`
  25. IdpId string `help:"filter by idp id"`
  26. AdminId []string
  27. OrderByDomain string `help:"order by domain name" choices:"asc|desc"`
  28. }
  29. func (opts *ProjectListOptions) Params() (jsonutils.JSONObject, error) {
  30. return options.ListStructToParams(opts)
  31. }
  32. type ProjectGetPropertyTagValuePairOptions struct {
  33. ProjectListOptions
  34. options.TagValuePairsOptions
  35. }
  36. func (opts *ProjectGetPropertyTagValuePairOptions) Params() (jsonutils.JSONObject, error) {
  37. params, err := opts.ProjectListOptions.Params()
  38. if err != nil {
  39. return nil, errors.Wrap(err, "ProjectListOptions.Params")
  40. }
  41. tagParams, _ := opts.TagValuePairsOptions.Params()
  42. params.(*jsonutils.JSONDict).Update(tagParams)
  43. return params, nil
  44. }
  45. type ProjectGetPropertyTagValueTreeOptions struct {
  46. ProjectListOptions
  47. options.TagValueTreeOptions
  48. }
  49. func (opts *ProjectGetPropertyTagValueTreeOptions) Params() (jsonutils.JSONObject, error) {
  50. params, err := opts.ProjectListOptions.Params()
  51. if err != nil {
  52. return nil, errors.Wrap(err, "ProjectListOptions.Params")
  53. }
  54. tagParams, _ := opts.TagValueTreeOptions.Params()
  55. params.(*jsonutils.JSONDict).Update(tagParams)
  56. return params, nil
  57. }
  58. type ProjectGetPropertyDomainTagValuePairOptions struct {
  59. ProjectListOptions
  60. options.DomainTagValuePairsOptions
  61. }
  62. func (opts *ProjectGetPropertyDomainTagValuePairOptions) Params() (jsonutils.JSONObject, error) {
  63. params, err := opts.ProjectListOptions.Params()
  64. if err != nil {
  65. return nil, errors.Wrap(err, "ProjectListOptions.Params")
  66. }
  67. tagParams, _ := opts.DomainTagValuePairsOptions.Params()
  68. params.(*jsonutils.JSONDict).Update(tagParams)
  69. return params, nil
  70. }
  71. type ProjectGetPropertyDomainTagValueTreeOptions struct {
  72. ProjectListOptions
  73. options.DomainTagValueTreeOptions
  74. }
  75. func (opts *ProjectGetPropertyDomainTagValueTreeOptions) Params() (jsonutils.JSONObject, error) {
  76. params, err := opts.ProjectListOptions.Params()
  77. if err != nil {
  78. return nil, errors.Wrap(err, "ProjectListOptions.Params")
  79. }
  80. tagParams, _ := opts.DomainTagValueTreeOptions.Params()
  81. params.(*jsonutils.JSONDict).Update(tagParams)
  82. return params, nil
  83. }
  84. type ProjectIdOptions struct {
  85. ID string `help:"ID or name of project" json:"-"`
  86. }
  87. func (opts *ProjectIdOptions) GetId() string {
  88. return opts.ID
  89. }
  90. type ProjectSetAdminOptions struct {
  91. ProjectIdOptions
  92. api.SProjectSetAdminInput
  93. }
  94. func (opts *ProjectSetAdminOptions) Params() (jsonutils.JSONObject, error) {
  95. return jsonutils.Marshal(opts), nil
  96. }
  97. type ProjectCleanOptions struct {
  98. }
  99. func (opts *ProjectCleanOptions) Params() (jsonutils.JSONObject, error) {
  100. return jsonutils.Marshal(opts), nil
  101. }