users.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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/onecloud/pkg/mcclient/options"
  18. )
  19. type UserListOptions struct {
  20. options.BaseListOptions
  21. Name string `help:"Filter by name"`
  22. OrderByDomain string `help:"order by domain name" choices:"asc|desc"`
  23. Role string `help:"Filter by role"`
  24. RoleAssignmentDomainId string `help:"filter role assignment domain"`
  25. RoleAssignmentProjectId string `help:"filter role assignment project"`
  26. IdpId string `help:"filter by idp_id"`
  27. IdpEntityId string `help:"filter by idp_entity_id"`
  28. }
  29. func (opts *UserListOptions) Params() (jsonutils.JSONObject, error) {
  30. return options.ListStructToParams(opts)
  31. }
  32. type UserIdOptions struct {
  33. ID string `help:"ID or name of user"`
  34. }
  35. func (opts *UserIdOptions) GetId() string {
  36. return opts.ID
  37. }
  38. type UserDetailOptions struct {
  39. UserIdOptions
  40. Domain string `help:"Domain"`
  41. }
  42. func (opts *UserDetailOptions) Params() (jsonutils.JSONObject, error) {
  43. ret := jsonutils.NewDict()
  44. if len(opts.Domain) > 0 {
  45. ret.Add(jsonutils.NewString(opts.Domain), "domain_id")
  46. }
  47. return ret, nil
  48. }